[PATCH] mount.cifs: make return codes match the return codes for
/bin/mount
Jeff Layton
jlayton at redhat.com
Wed Oct 8 15:51:06 GMT 2008
The manpage for /bin/mount specifies that the return code should be a
positive integer (actually, it's a bitfield). Clean up the return
codes from mount.cifs to make them match the expected return values
from /bin/mount. This necessary for proper integration with autofs.
Signed-off-by: Jeff Layton <jlayton at redhat.com>
---
source3/client/mount.cifs.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c
index b7a76c6..4a6477c 100644
--- a/source3/client/mount.cifs.c
+++ b/source3/client/mount.cifs.c
@@ -1228,13 +1228,13 @@ int main(int argc, char ** argv)
}
if (orgoptions && parse_options(&orgoptions, &flags)) {
- rc = -1;
+ rc = 1;
goto mount_exit;
}
ipaddr = parse_server(&share_name);
if((ipaddr == NULL) && (got_ip == 0)) {
printf("No ip address specified and hostname not found\n");
- rc = -1;
+ rc = 1;
goto mount_exit;
}
@@ -1249,19 +1249,19 @@ int main(int argc, char ** argv)
}
if(chdir(mountpoint)) {
printf("mount error: can not change directory into mount target %s\n",mountpoint);
- rc = -1;
+ rc = 1;
goto mount_exit;
}
if(stat (".", &statbuf)) {
printf("mount error: mount point %s does not exist\n",mountpoint);
- rc = -1;
+ rc = 1;
goto mount_exit;
}
if (S_ISDIR(statbuf.st_mode) == 0) {
printf("mount error: mount point %s is not a directory\n",mountpoint);
- rc = -1;
+ rc = 1;
goto mount_exit;
}
@@ -1274,7 +1274,7 @@ int main(int argc, char ** argv)
#endif
} else {
printf("mount error: permission denied or not superuser and mount.cifs not installed SUID\n");
- return -1;
+ return 1;
}
}
@@ -1289,7 +1289,7 @@ int main(int argc, char ** argv)
mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1);
if (!tmp_pass || !mountpassword) {
printf("Password not entered, exiting\n");
- return -1;
+ return 1;
}
strlcpy(mountpassword, tmp_pass, MOUNT_PASSWD_SIZE+1);
got_password = 1;
@@ -1321,7 +1321,7 @@ mount_retry:
if(options == NULL) {
printf("Could not allocate memory for mount options\n");
- return -1;
+ return 2;
}
options[0] = 0;
@@ -1400,8 +1400,7 @@ mount_retry:
printf("mount error %d = %s\n",errno,strerror(errno));
}
printf("Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)\n");
- rc = -1;
- goto mount_exit;
+ rc = 32;
} else {
pmntfile = setmntent(MOUNTED, "a+");
if(pmntfile) {
@@ -1439,11 +1438,13 @@ mount_retry:
rc = addmntent(pmntfile,&mountent);
endmntent(pmntfile);
SAFE_FREE(mountent.mnt_opts);
+ if (rc)
+ rc = 16;
} else {
- printf("could not update mount table\n");
+ printf("could not update mount table\n");
+ rc = 16;
}
}
- rc = 0;
mount_exit:
if(mountpassword) {
int len = strlen(mountpassword);
--
1.5.5.1
More information about the samba-technical
mailing list