Redo mount(2)/umount(2) ABI

- pass in file system type through mount(2), and return this type in
  statvfs structures as generated by [f]statvfs(2);
- align mount flags field with NetBSD's, splitting out service flags
  which are not to be passed to VFS;
- remove limitation of mount ABI to 16-byte labels, so that labels
  can be made larger in the future;
- introduce new m11 message union type for mount(2) as side effect.

Change-Id: I88b7710e297e00a5e4582ada5243d3d5c2801fd9
This commit is contained in:
David van Moolenbroek
2014-02-18 11:25:01 +01:00
committed by sambuc
parent 61ed526374
commit 7113bcb896
15 changed files with 137 additions and 118 deletions
-1
View File
@@ -920,7 +920,6 @@
#define stime _stime
#define umask _umask
#define umount _umount
#define umount2 _umount2
#define unlink _unlink
#define vm_remap _vm_remap
#define vm_unmap _vm_unmap
+24 -34
View File
@@ -16,7 +16,6 @@
#ifdef __weak_alias
__weak_alias(mount, _mount)
__weak_alias(umount, _umount)
__weak_alias(umount2, _umount2)
#endif
#define FSDEFAULT "mfs"
@@ -33,9 +32,9 @@ static int rs_down(char *label)
}
char *find_rslabel(char *args_line);
int mount(special, name, mountflags, type, args)
int mount(special, name, mountflags, srvflags, type, args)
char *name, *special, *type, *args;
int mountflags;
int mountflags, srvflags;
{
int r;
message m;
@@ -54,16 +53,12 @@ int mountflags;
reuse = 0;
memset(path, '\0', sizeof(path));
/* Check mount flags */
if(mountflags & MS_REUSE) {
/* Check service flags. */
if(srvflags & MS_REUSE)
reuse = 1;
mountflags &= ~MS_REUSE; /* Temporary: turn off to not confuse VFS */
}
if(mountflags & MS_EXISTING) {
if(srvflags & MS_EXISTING)
use_existing = 1;
mountflags &= ~MS_EXISTING; /* Temporary: turn off to not confuse VFS */
}
/* Make a label for the file system process. This label must be unique and
* may currently not exceed 16 characters including terminating null. For
@@ -104,9 +99,6 @@ int mountflags;
}
}
/* Tell VFS that we are passing in a 16-byte label. */
mountflags |= MS_LABEL16;
/* Sanity check on user input. */
if(strchr(args, '\'')) {
errno = EINVAL;
@@ -156,12 +148,15 @@ int mountflags;
}
/* Now perform mount(). */
m.m1_i1 = special ? strlen(special) + 1 : 0;
m.m1_i2 = strlen(name) + 1;
m.m1_i3 = mountflags;
m.m1_p1 = special;
m.m1_p2 = name;
m.m1_p3 = label;
m.VFS_MOUNT_FLAGS = mountflags;
m.VFS_MOUNT_DEVLEN = special ? strlen(special) + 1 : 0;
m.VFS_MOUNT_PATHLEN = strlen(name) + 1;
m.VFS_MOUNT_TYPELEN = strlen(type) + 1;
m.VFS_MOUNT_LABELLEN = strlen(label) + 1;
m.VFS_MOUNT_DEV = special;
m.VFS_MOUNT_PATH = name;
m.VFS_MOUNT_TYPE = type;
m.VFS_MOUNT_LABEL = label;
r = _syscall(VFS_PROC_NR, MOUNT, &m);
if (r != OK && !use_existing) {
@@ -174,30 +169,25 @@ int mountflags;
return r;
}
int umount(name)
int umount(name, srvflags)
const char *name;
int srvflags;
{
return umount2(name, 0);
}
int umount2(name, flags)
const char *name;
int flags;
{
char label[16];
message m;
int r;
_loadname(name, &m);
m.VFS_UMOUNT_NAME = __UNCONST(name);
m.VFS_UMOUNT_NAMELEN = strlen(name) + 1;
m.VFS_UMOUNT_LABEL = label;
m.VFS_UMOUNT_LABELLEN = sizeof(label);
r = _syscall(VFS_PROC_NR, UMOUNT, &m);
/* don't shut down the driver when exist flag is set */
if (!(flags & MS_EXISTING)) {
if (!(srvflags & MS_EXISTING)) {
if (r == OK) {
/* VFS returns the label of the unmounted file system in the reply.
* As of writing, the size of the m3_ca1 field is 16 bytes.
*/
rs_down(m.m3_ca1);
/* VFS returns the label of the unmounted file system to us. */
rs_down(label);
}
}