The Samba-Bugzilla – Attachment 3143 Details for
Bug 4370
umount.cfis does not remove mtab entry for relative links
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to unmount a filesyetem specified by not absolute path
umount.patch (text/plain), 2.56 KB, created by
shirishpargaonkar@gmail.com
on 2008-02-22 09:19:28 UTC
(
hide
)
Description:
patch to unmount a filesyetem specified by not absolute path
Filename:
MIME Type:
Creator:
shirishpargaonkar@gmail.com
Created:
2008-02-22 09:19:28 UTC
Size:
2.56 KB
patch
obsolete
>--- client.orig/umount.cifs.c 2008-02-22 05:58:37.000000000 -0600 >+++ client/umount.cifs.c 2008-02-22 06:03:09.000000000 -0600 >@@ -251,12 +251,13 @@ static int remove_from_mtab(char * mount > int main(int argc, char ** argv) > { > int c; >- int rc; >+ int rc = 0; > int flags = 0; > int nomtab = 0; > int retry_remount = 0; > struct statfs statbuf; >- char * mountpoint; >+ char *mountpoint = NULL; >+ char *dirpoint = NULL; > > if(argc && argv) { > thisprogram = argv[0]; >@@ -321,17 +322,12 @@ int main(int argc, char ** argv) > argv += optind; > argc -= optind; > >- mountpoint = argv[0]; >- > if((argc < 1) || (argv[0] == NULL)) { > printf("\nMissing name of unmount directory\n"); > umount_cifs_usage(); > return -EINVAL; > } > >- if(verboseflg) >- printf("optind %d unmount dir %s\n",optind, mountpoint); >- > /* check if running effectively root */ > if(geteuid() != 0) { > printf("Trying to unmount when %s not installed suid\n",thisprogram); >@@ -340,6 +336,27 @@ int main(int argc, char ** argv) > return -EACCES; > } > >+ if (argv[0][0] != '/') { >+ dirpoint = getcwd(NULL, 0); >+ if (!dirpoint) { >+ printf("get current working directory failed\n"); >+ return (errno); >+ } >+ mountpoint = malloc(strlen(dirpoint) + strlen(argv[0]) + 1); >+ if (!mountpoint) { >+ printf("Memory allocation failed\n"); >+ free(dirpoint); >+ return (ENOMEM); >+ } >+ strcat(mountpoint, dirpoint); >+ strcat(mountpoint, "/"); >+ strcat(mountpoint, argv[0]); >+ } else >+ mountpoint = argv[0]; /* absolute path of the mount point */ >+ >+ if (verboseflg) >+ printf("optind %d unmount dir %s\n", optind, mountpoint); >+ > /* fixup path if needed */ > > /* Trim any trailing slashes */ >@@ -354,14 +371,15 @@ int main(int argc, char ** argv) > > if(rc || (statbuf.f_type != CIFS_MAGIC_NUMBER)) { > printf("This utility only unmounts cifs filesystems.\n"); >- return -EINVAL; >+ rc = -EINVAL; >+ goto umountret; > } > > /* check if our uid was the one who mounted */ > rc = umount_check_perm(mountpoint); > if (rc) { > printf("Not permitted to unmount\n"); >- return rc; >+ goto umountret; > } > > if(umount2(mountpoint, flags)) { >@@ -374,7 +392,8 @@ int main(int argc, char ** argv) > printf("unmount error %d = %s\n",errno,strerror(errno)); > } > printf("Refer to the umount.cifs(8) manual page (man 8 umount.cifs)\n"); >- return -1; >+ rc = -1; >+ goto umountret; > } else { > if(verboseflg) > printf("umount2 succeeded\n"); >@@ -382,6 +401,12 @@ int main(int argc, char ** argv) > remove_from_mtab(mountpoint); > } > >- return 0; >+umountret: >+ if (dirpoint) { >+ free(dirpoint); >+ free(mountpoint); >+ } >+ >+ return rc; > } >
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 Raw
Actions:
View
Attachments on
bug 4370
: 3143 |
3148
|
3905
|
3906