mount: print errno on NFS error (again)
This commit is contained in:
parent
f223efbcde
commit
0e2c9fb4e0
@ -733,7 +733,10 @@ extern int get_linux_version_code(void);
|
|||||||
|
|
||||||
extern char *query_loop(const char *device);
|
extern char *query_loop(const char *device);
|
||||||
extern int del_loop(const char *device);
|
extern int del_loop(const char *device);
|
||||||
extern int set_loop(char **device, const char *file, unsigned long long offset);
|
/* If *devname is not NULL, use that name, otherwise try to find free one,
|
||||||
|
* malloc and return it in *devname.
|
||||||
|
* return value: 1: read-only loopdev was setup, 0: rw, < 0: error */
|
||||||
|
extern int set_loop(char **devname, const char *file, unsigned long long offset);
|
||||||
|
|
||||||
|
|
||||||
//TODO: pass buf pointer or return allocated buf (avoid statics)?
|
//TODO: pass buf pointer or return allocated buf (avoid statics)?
|
||||||
@ -1061,6 +1064,7 @@ extern const char bb_default_login_shell[];
|
|||||||
#endif
|
#endif
|
||||||
# define VC_FORMAT "/dev/vc/%d"
|
# define VC_FORMAT "/dev/vc/%d"
|
||||||
# define LOOP_FORMAT "/dev/loop/%d"
|
# define LOOP_FORMAT "/dev/loop/%d"
|
||||||
|
# define LOOP_NAMESIZE (sizeof("/dev/loop/") + sizeof(int)*3 + 1)
|
||||||
# define LOOP_NAME "/dev/loop/"
|
# define LOOP_NAME "/dev/loop/"
|
||||||
# define FB_0 "/dev/fb/0"
|
# define FB_0 "/dev/fb/0"
|
||||||
#else
|
#else
|
||||||
@ -1081,6 +1085,7 @@ extern const char bb_default_login_shell[];
|
|||||||
#endif
|
#endif
|
||||||
# define VC_FORMAT "/dev/tty%d"
|
# define VC_FORMAT "/dev/tty%d"
|
||||||
# define LOOP_FORMAT "/dev/loop%d"
|
# define LOOP_FORMAT "/dev/loop%d"
|
||||||
|
# define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1)
|
||||||
# define LOOP_NAME "/dev/loop"
|
# define LOOP_NAME "/dev/loop"
|
||||||
# define FB_0 "/dev/fb0"
|
# define FB_0 "/dev/fb0"
|
||||||
#endif
|
#endif
|
||||||
|
@ -81,7 +81,8 @@ int del_loop(const char *device)
|
|||||||
*/
|
*/
|
||||||
int set_loop(char **device, const char *file, unsigned long long offset)
|
int set_loop(char **device, const char *file, unsigned long long offset)
|
||||||
{
|
{
|
||||||
char dev[20], *try;
|
char dev[LOOP_NAMESIZE];
|
||||||
|
char *try;
|
||||||
bb_loop_info loopinfo;
|
bb_loop_info loopinfo;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
int i, dfd, ffd, mode, rc = -1;
|
int i, dfd, ffd, mode, rc = -1;
|
||||||
@ -140,14 +141,14 @@ int set_loop(char **device, const char *file, unsigned long long offset)
|
|||||||
rc = -1;
|
rc = -1;
|
||||||
}
|
}
|
||||||
close(dfd);
|
close(dfd);
|
||||||
try_again:
|
try_again:
|
||||||
if (*device) break;
|
if (*device) break;
|
||||||
}
|
}
|
||||||
close(ffd);
|
close(ffd);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
if (!*device)
|
if (!*device)
|
||||||
*device = xstrdup(dev);
|
*device = xstrdup(dev);
|
||||||
return (mode == O_RDONLY) ? 1 : 0;
|
return (mode == O_RDONLY); /* 1:ro, 0:rw */
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,10 @@ void bb_perror_msg(const char *s, ...)
|
|||||||
va_list p;
|
va_list p;
|
||||||
|
|
||||||
va_start(p, s);
|
va_start(p, s);
|
||||||
bb_vperror_msg(s, p);
|
/* Guard against "<error message>: Success" */
|
||||||
|
if (!errno)
|
||||||
|
bb_verror_msg(s, p, NULL);
|
||||||
|
else
|
||||||
|
bb_vperror_msg(s, p);
|
||||||
va_end(p);
|
va_end(p);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,11 @@ void bb_perror_msg_and_die(const char *s, ...)
|
|||||||
va_list p;
|
va_list p;
|
||||||
|
|
||||||
va_start(p, s);
|
va_start(p, s);
|
||||||
bb_vperror_msg(s, p);
|
/* Guard against "<error message>: Success" */
|
||||||
|
if (!errno)
|
||||||
|
bb_verror_msg(s, p, NULL);
|
||||||
|
else
|
||||||
|
bb_vperror_msg(s, p);
|
||||||
va_end(p);
|
va_end(p);
|
||||||
xfunc_die();
|
xfunc_die();
|
||||||
}
|
}
|
||||||
|
@ -1439,7 +1439,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
|
|||||||
// Might this be an NFS filesystem?
|
// Might this be an NFS filesystem?
|
||||||
|
|
||||||
if (ENABLE_FEATURE_MOUNT_NFS
|
if (ENABLE_FEATURE_MOUNT_NFS
|
||||||
&& (!mp->mnt_type || !strcmp(mp->mnt_type,"nfs"))
|
&& (!mp->mnt_type || !strcmp(mp->mnt_type, "nfs"))
|
||||||
&& strchr(mp->mnt_fsname, ':') != NULL
|
&& strchr(mp->mnt_fsname, ':') != NULL
|
||||||
) {
|
) {
|
||||||
rc = nfsmount(mp, vfsflags, filteropts);
|
rc = nfsmount(mp, vfsflags, filteropts);
|
||||||
@ -1458,15 +1458,12 @@ static int singlemount(struct mntent *mp, int ignore_busy)
|
|||||||
|
|
||||||
if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
|
if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
|
||||||
loopFile = bb_simplify_path(mp->mnt_fsname);
|
loopFile = bb_simplify_path(mp->mnt_fsname);
|
||||||
mp->mnt_fsname = 0;
|
mp->mnt_fsname = NULL; /* will receive malloced loop dev name */
|
||||||
switch (set_loop(&(mp->mnt_fsname), loopFile, 0)) {
|
if (set_loop(&(mp->mnt_fsname), loopFile, 0) < 0) {
|
||||||
case 0:
|
if (errno == EPERM || errno == EACCES)
|
||||||
case 1:
|
bb_error_msg(bb_msg_perm_denied_are_you_root);
|
||||||
break;
|
else
|
||||||
default:
|
bb_perror_msg("cannot setup loop device");
|
||||||
bb_error_msg( errno == EPERM || errno == EACCES
|
|
||||||
? bb_msg_perm_denied_are_you_root
|
|
||||||
: "cannot setup loop device");
|
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1516,10 +1513,10 @@ static int singlemount(struct mntent *mp, int ignore_busy)
|
|||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
free(filteropts);
|
free(filteropts);
|
||||||
|
|
||||||
if (rc && errno == EBUSY && ignore_busy) rc = 0;
|
if (rc && errno == EBUSY && ignore_busy)
|
||||||
|
rc = 0;
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
/* perror here sometimes says "mounting ... on ... failed: Success" */
|
bb_perror_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir);
|
||||||
bb_error_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -1527,7 +1524,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
|
|||||||
// Parse options, if necessary parse fstab/mtab, and call singlemount for
|
// Parse options, if necessary parse fstab/mtab, and call singlemount for
|
||||||
// each directory to be mounted.
|
// each directory to be mounted.
|
||||||
|
|
||||||
const char must_be_root[] = "you must be root";
|
static const char must_be_root[] = "you must be root";
|
||||||
|
|
||||||
int mount_main(int argc, char **argv);
|
int mount_main(int argc, char **argv);
|
||||||
int mount_main(int argc, char **argv)
|
int mount_main(int argc, char **argv)
|
||||||
|
Loading…
Reference in New Issue
Block a user