diff options
author | Jeff Layton <jlayton@samba.org> | 2011-01-31 15:04:35 -0500 |
---|---|---|
committer | Jeff Layton <jlayton@samba.org> | 2011-01-31 15:04:35 -0500 |
commit | fba28cfe2f13dd8bdae3cec76178f42b001a40ca (patch) | |
tree | 4a6b522472aea9051a620e1ad546589238c58f89 | |
parent | 51e3999b5fcd76502e05325174f34e0428c4742e (diff) | |
download | cifs-utils-fba28cfe2f13dd8bdae3cec76178f42b001a40ca.tar.gz cifs-utils-fba28cfe2f13dd8bdae3cec76178f42b001a40ca.tar.bz2 cifs-utils-fba28cfe2f13dd8bdae3cec76178f42b001a40ca.zip |
mount.cifs: don't try to alter mtab if it's a symlink
Some distros replace /etc/mtab with a symlink to /proc/mounts. In that
situation, mount.cifs will hang for a while trying to lock the mtab.
/bin/mount checks to see if the mtab is a symlink. If it is or if a
stat() call on it fails, it doesn't try to to update the mtab. Have
mount.cifs do the same.
Signed-off-by: Jeff Layton <jlayton@samba.org>
-rw-r--r-- | mount.cifs.c | 2 | ||||
-rw-r--r-- | mount.h | 1 | ||||
-rw-r--r-- | mtab.c | 16 |
3 files changed, 18 insertions, 1 deletions
diff --git a/mount.cifs.c b/mount.cifs.c index f537a07..5f29761 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -1934,7 +1934,7 @@ mount_retry: goto mount_exit; } - if (!parsed_info->nomtab) + if (!parsed_info->nomtab && !mtab_unusable()) rc = add_mtab(orig_dev, mountpoint, parsed_info->flags, fstype); mount_exit: @@ -32,6 +32,7 @@ #define _PATH_MOUNTED_LOCK _PATH_MOUNTED "~" #define _PATH_MOUNTED_TMP _PATH_MOUNTED ".tmp" +extern int mtab_unusable(void); extern int lock_mtab(void); extern void unlock_mtab(void); @@ -77,6 +77,22 @@ mono_time(void) { return ret; } +/* + * See if mtab is present and whether it's a symlink. Returns errno from stat() + * call or EMLINK if it's a symlink. + */ +int +mtab_unusable(void) +{ + struct stat mstat; + + if(lstat(_PATH_MOUNTED, &mstat)) + return errno; + else if (S_ISLNK(mstat.st_mode)) + return EMLINK; + return 0; +} + /* Remove lock file. */ void unlock_mtab (void) { |