Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 159609 Details for
Bug 248961
Autofs does not gracefully handle the MTAB_NOTUPDATED exit code from [u]mount
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Gracefully handle the mtab notupdated exit code from mount/umount.
autofs-4.1.3-handle-mtab-notupdated.patch (text/plain), 10.46 KB, created by
Jeff Moyer
on 2007-07-19 20:49:37 UTC
(
hide
)
Description:
Gracefully handle the mtab notupdated exit code from mount/umount.
Filename:
MIME Type:
Creator:
Jeff Moyer
Created:
2007-07-19 20:49:37 UTC
Size:
10.46 KB
patch
obsolete
>--- autofs-4.1.3/daemon/automount.c.orig 2007-07-19 14:41:23.000000000 -0400 >+++ autofs-4.1.3/daemon/automount.c 2007-07-19 16:09:41.000000000 -0400 >@@ -194,8 +194,7 @@ static int umount_ent(const char *root, > > if (umount_ok || is_smbfs) { > wait_for_lock(); >- rv = spawnl(LOG_DEBUG, MOUNTED_LOCK, >- PATH_UMOUNT, PATH_UMOUNT, path_buf, NULL); >+ rv = spawn_umount(LOG_DEBUG, path_buf, NULL); > unlink(AUTOFS_LOCK); > } > } >@@ -412,15 +411,7 @@ static int do_umount_autofs(void) > int ret; > > wait_for_lock(); >- rv = spawnl(LOG_DEBUG, MOUNTED_LOCK, >- PATH_UMOUNT, PATH_UMOUNT, ap.path, NULL); >- if (rv & MTAB_NOTUPDATED) { >- info("umount %s succeeded: " >- "mtab not updated, retrying to clean\n", >- ap.path); >- rv = spawnl(LOG_DEBUG, MOUNTED_LOCK, >- PATH_UMOUNT, PATH_UMOUNT, ap.path, NULL); >- } >+ rv = spawn_umount(LOG_DEBUG, ap.path, NULL); > unlink(AUTOFS_LOCK); > ret = stat(ap.path, &st); > if (rv == 0 || (ret == -1 && errno == ENOENT) || >@@ -524,8 +515,7 @@ static int unlink_mount_tree(const char > if (mptr->pid) > kill(mptr->pid, SIGKILL); > >- rv = spawnl(LOG_DEBUG, MOUNTED_LOCK, >- PATH_UMOUNT, PATH_UMOUNT, "-l", mptr->path, NULL); >+ rv = spawn_umount(LOG_DEBUG, "-l", mptr->path, NULL); > save_errno = errno; > if (rv == -1) { > ret = 0; >@@ -630,8 +620,8 @@ static int mount_autofs(char *path) > our_name[len] = '\0'; > > wait_for_lock(); >- if (spawnl(LOG_DEBUG, MOUNTED_LOCK, PATH_MOUNT, PATH_MOUNT, >- "-t", "autofs", "-o", options, our_name, path, NULL) != 0) { >+ if (spawn_mount(LOG_DEBUG, "-t", "autofs", "-o", >+ options, our_name, path, NULL) != 0) { > crit("failed to mount autofs path %s", ap.path); > unlink(AUTOFS_LOCK); > rmdir_path(ap.path); >--- autofs-4.1.3/daemon/spawn.c.orig 2007-07-19 10:36:11.000000000 -0400 >+++ autofs-4.1.3/daemon/spawn.c 2007-07-19 16:34:18.000000000 -0400 >@@ -254,3 +254,128 @@ int spawnl(int logpri, const char *lockf > > return spawnv(logpri, lockf, prog, (const char **) argv); > } >+ >+int spawn_mount(int logpri, ...) >+{ >+ va_list arg; >+ int argc; >+ int retries = 0; >+ char **argv, **p; >+ char arg0[] = PATH_MOUNT; >+ char arg_fake[] = "-f"; /* pass the fake option to mount */ >+ int ret; >+ >+ va_start(arg, logpri); >+ /* >+ * The first argument is the program name. Then, reserve one slot >+ * for the NULL terminator, and one slot for the potential "-f" flag. >+ */ >+ for (argc = 3; va_arg(arg, char*); argc++); >+ va_end(arg); >+ >+ if (!(argv = alloca(sizeof(char *) * argc))) >+ return -1; >+ >+ argv[0] = arg0; >+ va_start(arg, logpri); >+ p = &argv[1]; >+ while ((*p++ = va_arg(arg, char *))); >+ va_end(arg); >+ >+ /* Remember, we reserved a space in the argument list for the >+ * -f option. */ >+ argv[argc - 2] = NULL; >+ argv[argc - 1] = NULL; >+ >+ while (retries++ < 3) { >+ ret = spawnv(logpri, MOUNTED_LOCK, >+ PATH_MOUNT, (const char **)argv); >+ if (ret & MTAB_NOTUPDATED) { >+ /* >+ * If the mount succeeded but the mtab was not >+ * updated, then retry the mount with the -f (fake) >+ * option to just update the mtab. >+ */ >+ debug("%s: mount failed with error code 16. Retrying " >+ "with the -f option.\n", __FUNCTION__); >+ argv[argc - 2] = arg_fake; >+ sleep(3); >+ } else >+ break; >+ } >+ >+ /* This is not a fatal error */ >+ if (ret == MTAB_NOTUPDATED) { >+ warn("%s: Unable to update the mtab file. /proc/mounts and" >+ " /etc/mtab will differ.", __FUNCTION__); >+ ret = 0; >+ } >+ return ret; >+} >+ >+int spawn_umount(int logpri, ...) >+{ >+ va_list arg; >+ int argc; >+ int retries = 0; >+ char **argv, **p; >+ char arg0[] = PATH_UMOUNT; >+ int ret, printed = 0; >+ >+ va_start(arg, logpri); >+ /* >+ * The first argument is the program name. Then, reserve one slot >+ * for the NULL terminator. >+ */ >+ for (argc = 2; va_arg(arg, char*); argc++); >+ va_end(arg); >+ >+ if (!(argv = alloca(sizeof(char *) * argc))) >+ return -1; >+ >+ argv[0] = arg0; >+ va_start(arg, logpri); >+ p = &argv[1]; >+ while ((*p++ = va_arg(arg, char *))); >+ va_end(arg); >+ >+ argv[argc - 1] = NULL; >+ while (retries++ < 3) { >+ ret = spawnv(logpri, MOUNTED_LOCK, >+ PATH_UMOUNT, (const char **)argv); >+ if (ret & MTAB_NOTUPDATED) { >+ /* >+ * If the mount succeeded but the mtab was not >+ * updated, then retry the mount with the -f (fake) >+ * option to just update the mtab. >+ */ >+ if (!printed) { >+ debug("%s: umount failed with error code 16. " >+ "Retrying with the -f option.\n", >+ __FUNCTION__); >+ printed = 1; >+ } >+ } else { >+ /* >+ * umount does not support the "fake" option. Thus, >+ * if we got a return value of MTAB_NOTUPDATED the >+ * first time, that means the umount actually >+ * succeeded. Then, a following umount will fail >+ * due to the fact that the fact that nothing was >+ * mounted on the mount point. So, report this as >+ * success. >+ */ >+ if (retries > 1) >+ ret = 0; >+ break; >+ } >+ } >+ >+ /* This is not a fatal error */ >+ if (ret == MTAB_NOTUPDATED) { >+ warn("%s: Unable to update the mtab file. /proc/mounts and" >+ " /etc/mtab will differ.", __FUNCTION__); >+ ret = 0; >+ } >+ return ret; >+} >--- autofs-4.1.3/include/automount.h.orig 2007-07-19 14:43:01.000000000 -0400 >+++ autofs-4.1.3/include/automount.h 2007-07-19 16:21:02.000000000 -0400 >@@ -138,6 +138,8 @@ const char *path_mounted; > void wait_for_lock(void); > int spawnl(int logpri, const char *lockf, const char *prog, ...); > int spawnv(int logpri, const char *lockf, const char *prog, const char *const *argv); >+int spawn_mount(int logpri, ...); >+int spawn_umount(int logpri, ...); > void reset_signals(void); > void ignore_signals(void); > void discard_pending(int sig); >--- autofs-4.1.3/modules/mount_ext2.c.orig 2007-07-19 15:08:42.000000000 -0400 >+++ autofs-4.1.3/modules/mount_ext2.c 2007-07-19 15:10:16.000000000 -0400 >@@ -114,15 +114,13 @@ int mount_mount(const char *root, const > if (options) { > debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s", > fstype, options, what, fullpath); >- err = spawnl(LOG_NOTICE, MOUNTED_LOCK, >- PATH_MOUNT, PATH_MOUNT, "-t", fstype, >- SLOPPYOPT "-o", options, what, fullpath, NULL); >+ err = spawn_mount(LOG_NOTICE, "-t", fstype, SLOPPYOPT "-o", >+ options, what, fullpath, NULL); > } else { > debug(MODPREFIX "calling mount -t %s %s %s", > fstype, what, fullpath); >- err = spawnl(LOG_NOTICE, MOUNTED_LOCK, >- PATH_MOUNT, PATH_MOUNT, "-t", fstype, >- what, fullpath, NULL); >+ err = spawn_mount(LOG_NOTICE, >+ "-t", fstype, what, fullpath, NULL); > } > unlink(AUTOFS_LOCK); > >--- autofs-4.1.3/modules/mount_nfs.c.orig 2007-07-19 15:11:42.000000000 -0400 >+++ autofs-4.1.3/modules/mount_nfs.c 2007-07-19 15:12:20.000000000 -0400 >@@ -280,16 +280,14 @@ int mount_mount(const char *root, const > if (nfsoptions && *nfsoptions) { > debug(MODPREFIX "calling mount -t %s " SLOPPY > "-o %s %s %s", fstype, nfsoptions, loc, fullpath); >- err = spawnl(LOG_NOTICE, MOUNTED_LOCK, >- PATH_MOUNT, PATH_MOUNT, "-t", fstype, >- SLOPPYOPT "-o", >- nfsoptions, loc, fullpath, NULL); >+ err = spawn_mount(LOG_NOTICE, "-t", fstype, >+ SLOPPYOPT "-o", >+ nfsoptions, loc, fullpath, NULL); > } else { > debug(MODPREFIX "calling mount -t %s %s %s", > fstype, loc, fullpath); >- err = spawnl(LOG_NOTICE, MOUNTED_LOCK, >- PATH_MOUNT, PATH_MOUNT, "-t", fstype, >- loc, fullpath, NULL); >+ err = spawn_mount(LOG_NOTICE, "-t", fstype, >+ loc, fullpath, NULL); > } > unlink(AUTOFS_LOCK); > >--- autofs-4.1.3/modules/mount_changer.c.orig 2007-07-19 15:05:49.000000000 -0400 >+++ autofs-4.1.3/modules/mount_changer.c 2007-07-19 16:13:00.000000000 -0400 >@@ -68,8 +68,7 @@ int mount_mount(const char *root, const > debug(MODPREFIX "calling umount %s", what); > > wait_for_lock(); >- err = spawnl(LOG_DEBUG, MOUNTED_LOCK, >- PATH_UMOUNT, PATH_UMOUNT, what, NULL); >+ err = spawn_umount(LOG_DEBUG, what, NULL); > unlink(AUTOFS_LOCK); > if (err) { > error(MODPREFIX "umount of %s failed (all may be unmounted)", >@@ -100,15 +99,13 @@ int mount_mount(const char *root, const > debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s", > fstype, options, what, fullpath); > >- err = spawnl(LOG_DEBUG, MOUNTED_LOCK, >- PATH_MOUNT, PATH_MOUNT, "-t", fstype, >- SLOPPYOPT "-o", options, what, fullpath, NULL); >+ err = spawn_mount(LOG_DEBUG, "-t", fstype, SLOPPYOPT "-o", >+ options, what, fullpath, NULL); > } else { > debug(MODPREFIX "calling mount -t %s %s %s", > fstype, what, fullpath); > >- err = spawnl(LOG_DEBUG, MOUNTED_LOCK, PATH_MOUNT, PATH_MOUNT, >- "-t", fstype, what, fullpath, NULL); >+ err = spawn_mount(LOG_DEBUG, "-t", fstype, what, fullpath, NULL); > } > unlink(AUTOFS_LOCK); > >--- autofs-4.1.3/modules/mount_generic.c.orig 2007-07-19 15:10:37.000000000 -0400 >+++ autofs-4.1.3/modules/mount_generic.c 2007-07-19 15:11:24.000000000 -0400 >@@ -78,15 +78,13 @@ int mount_mount(const char *root, const > debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s", > fstype, options, what, fullpath); > >- err = spawnl(LOG_NOTICE, MOUNTED_LOCK, >- PATH_MOUNT, PATH_MOUNT, "-t", fstype, >- SLOPPYOPT "-o", options, what, fullpath, NULL); >+ err = spawn_mount(LOG_NOTICE, "-t", fstype, SLOPPYOPT "-o", >+ options, what, fullpath, NULL); > } else { > debug(MODPREFIX "calling mount -t %s %s %s", > fstype, what, fullpath); >- err = spawnl(LOG_NOTICE, MOUNTED_LOCK, >- PATH_MOUNT, PATH_MOUNT, "-t", fstype, >- what, fullpath, NULL); >+ err = spawn_mount(LOG_NOTICE, >+ "-t", fstype, what, fullpath, NULL); > } > unlink(AUTOFS_LOCK); > >--- autofs-4.1.3/modules/mount_bind.c.orig 2007-07-19 14:23:29.000000000 -0400 >+++ autofs-4.1.3/modules/mount_bind.c 2007-07-19 15:37:58.000000000 -0400 >@@ -59,7 +59,7 @@ int mount_init(void **context) > if (lstat(tmp1, &st1) == -1) > goto out; > >- err = spawnl(LOG_DEBUG, MOUNTED_LOCK, >+ err = spawnl(LOG_DEBUG, NULL, > PATH_MOUNT, PATH_MOUNT, "-n", "--bind", tmp1, tmp2, NULL); > > if (err == 0 && >@@ -69,7 +69,7 @@ int mount_init(void **context) > } > > debug(MODPREFIX "bind_works = %d\n", bind_works); >- spawnl(LOG_DEBUG, MOUNTED_LOCK, >+ spawnl(LOG_DEBUG, NULL, > PATH_UMOUNT, PATH_UMOUNT, "-n", tmp2, NULL); > > out: >@@ -126,9 +126,7 @@ int mount_mount(const char *root, const > debug(MODPREFIX "calling mount --bind %s %s", what, fullpath); > > wait_for_lock(); >- err = spawnl(LOG_NOTICE, MOUNTED_LOCK, >- PATH_MOUNT, PATH_MOUNT, "--bind", >- what, fullpath, NULL); >+ err = spawn_mount(LOG_NOTICE, "--bind", what, fullpath, NULL); > unlink(AUTOFS_LOCK); > > if (err) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 248961
: 159609