summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-06-20 21:34:51 +0000
committerMiles Bader <miles@gnu.org>1996-06-20 21:34:51 +0000
commit957bb98d980426a65049f2657758b89993af7ae0 (patch)
treed52f87c12ac7bf85cfe88d3b73364bbebbc29d88
parent4e785a19d3055eaf34e7dc0a6c40385681774b5a (diff)
(fstypes_create): Copy SEARCH_FMTS contents into NEW.
(fs_set_mntent): Don't keep old fsys fields if the mnt_dir is changed. (fstab_add_mntent): Initialize fields in FS with non-zero values. (_fs_check_mounted): The root is always mounted.
-rw-r--r--sutils/fstab.c61
1 files changed, 44 insertions, 17 deletions
diff --git a/sutils/fstab.c b/sutils/fstab.c
index 8f780e81..5b8d17ca 100644
--- a/sutils/fstab.c
+++ b/sutils/fstab.c
@@ -80,6 +80,7 @@ fstypes_create (char *search_fmts, size_t search_fmts_len,
free (types);
return ENOMEM;
}
+ bcopy (search_fmts, new->program_search_fmts, search_fmts_len);
*types = new;
return 0;
}
@@ -179,6 +180,14 @@ fs_set_mntent (struct fs *fs, struct mntent *mntent)
if (! fs->storage)
return ENOMEM;
+ if (strcmp (fs->mntent.mnt_dir, mntent->mnt_dir) != 0)
+ {
+ fs->mounted = fs->readonly = -1;
+ if (fs->fsys != MACH_PORT_NULL)
+ mach_port_deallocate (mach_task_self (), fs->fsys);
+ fs->fsys = MACH_PORT_NULL;
+ }
+
/* Copy MNTENT into FS; string-valued fields will be fixed up next. */
fs->mntent = *mntent;
@@ -222,29 +231,45 @@ _fs_check_mounted (struct fs *fs)
if (fs->mounted < 0)
/* The mounted field in FS is -1 if we're not sure. */
{
- file_t mount_point =
- file_name_lookup_carefully (fs->mntent.mnt_dir, O_NOTRANS, 0);
+ if (fs->fsys != MACH_PORT_NULL)
+ mach_port_deallocate (mach_task_self (), fs->fsys);
- if (mount_point != MACH_PORT_NULL)
- /* The node exists. Is it the root of an active translator?
- [Note that it could be a different translator than the one in
- the mntent, but oh well, nothing we can do about that.] */
+ if (strcmp (fs->mntent.mnt_dir, "/") == 0)
+ /* The root is always mounted. Get its control port. */
{
- if (fs->fsys != MACH_PORT_NULL)
- mach_port_deallocate (mach_task_self (), fs->fsys);
- err = file_get_translator_cntl (mount_point, &fs->fsys);
- if (err == EINVAL || err == EOPNOTSUPP)
- /* Either the mount point doesn't exist, or wasn't mounted. */
+ file_t root = getcrdir ();
+ if (root == MACH_PORT_NULL)
+ err = errno;
+ else
{
- fs->fsys = MACH_PORT_NULL;
- err = 0;
+ err = file_getcontrol (root, &fs->fsys);
+ mach_port_deallocate (mach_task_self (), root);
}
}
- else if (errno == ENXIO)
- /* Ran into an inactive passive translator. FS can't be mounted. */
+ else
{
- fs->fsys = MACH_PORT_NULL;
- err = 0;
+ file_t mount_point =
+ file_name_lookup_carefully (fs->mntent.mnt_dir, O_NOTRANS, 0);
+
+ if (mount_point != MACH_PORT_NULL)
+ /* The node exists. Is it the root of an active translator?
+ [Note that it could be a different translator than the one in
+ the mntent, but oh well, nothing we can do about that.] */
+ {
+ err = file_get_translator_cntl (mount_point, &fs->fsys);
+ if (err == EINVAL || err == EOPNOTSUPP)
+ /* Either the mount point doesn't exist, or wasn't mounted. */
+ {
+ fs->fsys = MACH_PORT_NULL;
+ err = 0;
+ }
+ }
+ else if (errno == ENXIO)
+ /* Ran into an inactive passive translator. FS can't be mounted. */
+ {
+ fs->fsys = MACH_PORT_NULL;
+ err = 0;
+ }
}
if (! err)
@@ -424,6 +449,8 @@ fstab_add_mntent (struct fstab *fstab, struct mntent *mntent,
if (fs)
{
bzero (fs, sizeof (struct fs));
+ fs->mounted = fs->readonly = -1;
+ fs->fsys = MACH_PORT_NULL;
new = 1;
}
else