aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-08-03 14:16:24 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-08-03 14:16:24 +0000
commit0e2c9fb4e09fb0c5a47ddc74b0ba53238570599e (patch)
treeab1416450c6c339fdbe3422a4e4243e7d2098541
parentf223efbcde63c0c01e5b1331f2fc7f1a9c812f20 (diff)
downloadbusybox-w32-0e2c9fb4e09fb0c5a47ddc74b0ba53238570599e.tar.gz
busybox-w32-0e2c9fb4e09fb0c5a47ddc74b0ba53238570599e.tar.bz2
busybox-w32-0e2c9fb4e09fb0c5a47ddc74b0ba53238570599e.zip
mount: print errno on NFS error (again)
-rw-r--r--include/libbb.h7
-rw-r--r--libbb/loop.c7
-rw-r--r--libbb/perror_msg.c6
-rw-r--r--libbb/perror_msg_and_die.c6
-rw-r--r--util-linux/mount.c25
5 files changed, 31 insertions, 20 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 13bd2d688..546bbafc6 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -733,7 +733,10 @@ extern int get_linux_version_code(void);
733 733
734extern char *query_loop(const char *device); 734extern char *query_loop(const char *device);
735extern int del_loop(const char *device); 735extern int del_loop(const char *device);
736extern int set_loop(char **device, const char *file, unsigned long long offset); 736/* If *devname is not NULL, use that name, otherwise try to find free one,
737 * malloc and return it in *devname.
738 * return value: 1: read-only loopdev was setup, 0: rw, < 0: error */
739extern int set_loop(char **devname, const char *file, unsigned long long offset);
737 740
738 741
739//TODO: pass buf pointer or return allocated buf (avoid statics)? 742//TODO: pass buf pointer or return allocated buf (avoid statics)?
@@ -1061,6 +1064,7 @@ extern const char bb_default_login_shell[];
1061#endif 1064#endif
1062# define VC_FORMAT "/dev/vc/%d" 1065# define VC_FORMAT "/dev/vc/%d"
1063# define LOOP_FORMAT "/dev/loop/%d" 1066# define LOOP_FORMAT "/dev/loop/%d"
1067# define LOOP_NAMESIZE (sizeof("/dev/loop/") + sizeof(int)*3 + 1)
1064# define LOOP_NAME "/dev/loop/" 1068# define LOOP_NAME "/dev/loop/"
1065# define FB_0 "/dev/fb/0" 1069# define FB_0 "/dev/fb/0"
1066#else 1070#else
@@ -1081,6 +1085,7 @@ extern const char bb_default_login_shell[];
1081#endif 1085#endif
1082# define VC_FORMAT "/dev/tty%d" 1086# define VC_FORMAT "/dev/tty%d"
1083# define LOOP_FORMAT "/dev/loop%d" 1087# define LOOP_FORMAT "/dev/loop%d"
1088# define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1)
1084# define LOOP_NAME "/dev/loop" 1089# define LOOP_NAME "/dev/loop"
1085# define FB_0 "/dev/fb0" 1090# define FB_0 "/dev/fb0"
1086#endif 1091#endif
diff --git a/libbb/loop.c b/libbb/loop.c
index 9559d429a..6934b7a3b 100644
--- a/libbb/loop.c
+++ b/libbb/loop.c
@@ -81,7 +81,8 @@ int del_loop(const char *device)
81 */ 81 */
82int set_loop(char **device, const char *file, unsigned long long offset) 82int set_loop(char **device, const char *file, unsigned long long offset)
83{ 83{
84 char dev[20], *try; 84 char dev[LOOP_NAMESIZE];
85 char *try;
85 bb_loop_info loopinfo; 86 bb_loop_info loopinfo;
86 struct stat statbuf; 87 struct stat statbuf;
87 int i, dfd, ffd, mode, rc = -1; 88 int i, dfd, ffd, mode, rc = -1;
@@ -140,14 +141,14 @@ int set_loop(char **device, const char *file, unsigned long long offset)
140 rc = -1; 141 rc = -1;
141 } 142 }
142 close(dfd); 143 close(dfd);
143try_again: 144 try_again:
144 if (*device) break; 145 if (*device) break;
145 } 146 }
146 close(ffd); 147 close(ffd);
147 if (!rc) { 148 if (!rc) {
148 if (!*device) 149 if (!*device)
149 *device = xstrdup(dev); 150 *device = xstrdup(dev);
150 return (mode == O_RDONLY) ? 1 : 0; 151 return (mode == O_RDONLY); /* 1:ro, 0:rw */
151 } 152 }
152 return rc; 153 return rc;
153} 154}
diff --git a/libbb/perror_msg.c b/libbb/perror_msg.c
index 5145795f5..2ec1a9b2a 100644
--- a/libbb/perror_msg.c
+++ b/libbb/perror_msg.c
@@ -14,6 +14,10 @@ void bb_perror_msg(const char *s, ...)
14 va_list p; 14 va_list p;
15 15
16 va_start(p, s); 16 va_start(p, s);
17 bb_vperror_msg(s, p); 17 /* Guard against "<error message>: Success" */
18 if (!errno)
19 bb_verror_msg(s, p, NULL);
20 else
21 bb_vperror_msg(s, p);
18 va_end(p); 22 va_end(p);
19} 23}
diff --git a/libbb/perror_msg_and_die.c b/libbb/perror_msg_and_die.c
index 3a06b654b..90f56e04c 100644
--- a/libbb/perror_msg_and_die.c
+++ b/libbb/perror_msg_and_die.c
@@ -14,7 +14,11 @@ void bb_perror_msg_and_die(const char *s, ...)
14 va_list p; 14 va_list p;
15 15
16 va_start(p, s); 16 va_start(p, s);
17 bb_vperror_msg(s, p); 17 /* Guard against "<error message>: Success" */
18 if (!errno)
19 bb_verror_msg(s, p, NULL);
20 else
21 bb_vperror_msg(s, p);
18 va_end(p); 22 va_end(p);
19 xfunc_die(); 23 xfunc_die();
20} 24}
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 7ee24ca14..a7b0a98f0 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -1439,7 +1439,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1439 // Might this be an NFS filesystem? 1439 // Might this be an NFS filesystem?
1440 1440
1441 if (ENABLE_FEATURE_MOUNT_NFS 1441 if (ENABLE_FEATURE_MOUNT_NFS
1442 && (!mp->mnt_type || !strcmp(mp->mnt_type,"nfs")) 1442 && (!mp->mnt_type || !strcmp(mp->mnt_type, "nfs"))
1443 && strchr(mp->mnt_fsname, ':') != NULL 1443 && strchr(mp->mnt_fsname, ':') != NULL
1444 ) { 1444 ) {
1445 rc = nfsmount(mp, vfsflags, filteropts); 1445 rc = nfsmount(mp, vfsflags, filteropts);
@@ -1458,15 +1458,12 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1458 1458
1459 if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { 1459 if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
1460 loopFile = bb_simplify_path(mp->mnt_fsname); 1460 loopFile = bb_simplify_path(mp->mnt_fsname);
1461 mp->mnt_fsname = 0; 1461 mp->mnt_fsname = NULL; /* will receive malloced loop dev name */
1462 switch (set_loop(&(mp->mnt_fsname), loopFile, 0)) { 1462 if (set_loop(&(mp->mnt_fsname), loopFile, 0) < 0) {
1463 case 0: 1463 if (errno == EPERM || errno == EACCES)
1464 case 1: 1464 bb_error_msg(bb_msg_perm_denied_are_you_root);
1465 break; 1465 else
1466 default: 1466 bb_perror_msg("cannot setup loop device");
1467 bb_error_msg( errno == EPERM || errno == EACCES
1468 ? bb_msg_perm_denied_are_you_root
1469 : "cannot setup loop device");
1470 return errno; 1467 return errno;
1471 } 1468 }
1472 1469
@@ -1516,10 +1513,10 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1516 if (ENABLE_FEATURE_CLEAN_UP) 1513 if (ENABLE_FEATURE_CLEAN_UP)
1517 free(filteropts); 1514 free(filteropts);
1518 1515
1519 if (rc && errno == EBUSY && ignore_busy) rc = 0; 1516 if (rc && errno == EBUSY && ignore_busy)
1517 rc = 0;
1520 if (rc < 0) 1518 if (rc < 0)
1521 /* perror here sometimes says "mounting ... on ... failed: Success" */ 1519 bb_perror_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir);
1522 bb_error_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir);
1523 1520
1524 return rc; 1521 return rc;
1525} 1522}
@@ -1527,7 +1524,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1527// Parse options, if necessary parse fstab/mtab, and call singlemount for 1524// Parse options, if necessary parse fstab/mtab, and call singlemount for
1528// each directory to be mounted. 1525// each directory to be mounted.
1529 1526
1530const char must_be_root[] = "you must be root"; 1527static const char must_be_root[] = "you must be root";
1531 1528
1532int mount_main(int argc, char **argv); 1529int mount_main(int argc, char **argv);
1533int mount_main(int argc, char **argv) 1530int mount_main(int argc, char **argv)