Fixes for mount -a.
* Display an error message upon failure to mount a device. * Handle a special case when the source device is "none" * pass the mount options stored in fourth field of fstab to mount(3).
This commit is contained in:
parent
c9b3bd9d45
commit
1fb60d0811
@ -176,11 +176,14 @@ int
|
|||||||
mount_all()
|
mount_all()
|
||||||
{
|
{
|
||||||
struct fstab *fs;
|
struct fstab *fs;
|
||||||
|
int ro, mountflags;
|
||||||
char mountpoint[PATH_MAX];
|
char mountpoint[PATH_MAX];
|
||||||
|
char *device, *err;
|
||||||
|
|
||||||
while ((fs = getfsent()) != NULL) {
|
while ((fs = getfsent()) != NULL) {
|
||||||
int ro = 0;
|
ro = 0;
|
||||||
int mountflags = 0;
|
mountflags = 0;
|
||||||
|
device = NULL;
|
||||||
if (realpath(fs->fs_file, mountpoint) == NULL) {
|
if (realpath(fs->fs_file, mountpoint) == NULL) {
|
||||||
fprintf(stderr, "Can't mount on %s\n", fs->fs_file);
|
fprintf(stderr, "Can't mount on %s\n", fs->fs_file);
|
||||||
return(EXIT_FAILURE);
|
return(EXIT_FAILURE);
|
||||||
@ -191,16 +194,26 @@ mount_all()
|
|||||||
continue; /* Not remounting root */
|
continue; /* Not remounting root */
|
||||||
if (has_opt(fs->fs_mntops, "ro"))
|
if (has_opt(fs->fs_mntops, "ro"))
|
||||||
ro = 1;
|
ro = 1;
|
||||||
|
|
||||||
if (ro) {
|
if (ro) {
|
||||||
mountflags |= MS_RDONLY;
|
mountflags |= MS_RDONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mount(fs->fs_spec, mountpoint, mountflags, fs->fs_vfstype,
|
device = fs->fs_spec;
|
||||||
NULL) == 0) {
|
/* passing a null string for block special device means don't
|
||||||
|
* use a device at all and this is what we need to do for
|
||||||
|
* entries starting with "none"
|
||||||
|
*/
|
||||||
|
if (!strcmp(device, "none"))
|
||||||
|
device = NULL;
|
||||||
|
|
||||||
|
if (mount(device, mountpoint, mountflags, fs->fs_vfstype,
|
||||||
|
fs->fs_mntops) == 0) {
|
||||||
update_mtab(fs->fs_spec, fs->fs_file, fs->fs_vfstype,
|
update_mtab(fs->fs_spec, fs->fs_file, fs->fs_vfstype,
|
||||||
mountflags);
|
mountflags);
|
||||||
} else {
|
} else {
|
||||||
|
err = strerror(errno);
|
||||||
|
fprintf(stderr, "mount: Can't mount %s on %s: %s\n",
|
||||||
|
fs->fs_spec, fs->fs_file, err);
|
||||||
return(EXIT_FAILURE);
|
return(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user