Skip to content

Commit

Permalink
Merge d5c3a14 into b5a67f0
Browse files Browse the repository at this point in the history
  • Loading branch information
ldachary committed Mar 10, 2015
2 parents b5a67f0 + d5c3a14 commit 9ecf80a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/mount/mtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/vfs.h>
#include <time.h>
#include <mntent.h>
#include <stdarg.h>
Expand All @@ -44,6 +45,7 @@ setlkw_timeout (int sig) {

#define _PATH_MOUNTED "/etc/mtab"
#define _PATH_MOUNTED_LOCK "/etc/mtab~"
#define PROC_SUPER_MAGIC 0x9fa0

/* exit status - bits below are ORed */
#define EX_USAGE 1 /* incorrect invocation or permission */
Expand Down Expand Up @@ -245,11 +247,21 @@ lock_mtab (void) {
static void
update_mtab_entry(const char *spec, const char *node, const char *type,
const char *opts, int flags, int freq, int pass) {
struct mntent mnt;
struct statfs buf;
int err = statfs(_PATH_MOUNTED, &buf);
if (err) {
printf("mount: can't statfs %s: %s", _PATH_MOUNTED,
strerror (err));
return;
}
/* /etc/mtab is symbol link to /proc/self/mounts? */
if (buf.f_type == PROC_SUPER_MAGIC)
return;

if (!opts)
opts = "rw";

struct mntent mnt;
mnt.mnt_fsname = strdup(spec);
mnt.mnt_dir = canonicalize_path(node);
mnt.mnt_type = strdup(type);
Expand Down

0 comments on commit 9ecf80a

Please sign in to comment.