tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: wedge device to name



On Sep 22,  5:58pm, n54%gmx.com@localhost (Kamil Rytarowski) wrote:
-- Subject: Re: wedge device to name

| I understand and I know. Unfortunately (or fortunately) we will need to
| live with the old syscall forever.

Yes, but cleaning the old code is obvious and simple. Untangling the
sysctl-augmented API mess is nearly impossible.

| A programmer friendly wrapper of sysctl could be implemented in libutil.

That is not really needed for the userland part; there is sysctlybyname();

Here's the actual change compared to ~100s of lines of sysctl code:

Index: kern/vfs_subr.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_subr.c,v
retrieving revision 1.471
diff -u -u -r1.471 vfs_subr.c
--- kern/vfs_subr.c	1 Jan 2019 10:06:54 -0000	1.471
+++ kern/vfs_subr.c	22 Sep 2019 16:17:49 -0000
@@ -1198,6 +1198,8 @@
 	    sizeof(sbp->f_mntonname));
 	(void)memcpy(sbp->f_mntfromname, mp->mnt_stat.f_mntfromname,
 	    sizeof(sbp->f_mntfromname));
+	(void)memcpy(sbp->f_mntfromlabel, mp->mnt_stat.f_mntfromlabel,
+	    sizeof(sbp->f_mntfromlabel));
 	sbp->f_namemax = mbp->f_namemax;
 }
 
Index: sys/statvfs.h
===================================================================
RCS file: /cvsroot/src/sys/sys/statvfs.h,v
retrieving revision 1.18
diff -u -b -w -u -r1.18 statvfs.h
--- sys/statvfs.h	5 Apr 2013 17:34:27 -0000	1.18
+++ sys/statvfs.h	22 Sep 2019 16:18:43 -0000
@@ -96,6 +96,7 @@
 	char	f_fstypename[_VFS_NAMELEN]; /* fs type name */
 	char	f_mntonname[_VFS_MNAMELEN];  /* directory on which mounted */
 	char	f_mntfromname[_VFS_MNAMELEN];  /* mounted file system */
+	char	f_mntfromlabel[_VFS_MNAMELEN];  /* disk label name if available */
 
 };
 
Index: miscfs/specfs/spec_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/miscfs/specfs/spec_vnops.c,v
retrieving revision 1.175
diff -u -r1.175 spec_vnops.c
--- miscfs/specfs/spec_vnops.c	3 Sep 2018 16:29:35 -0000	1.175
+++ miscfs/specfs/spec_vnops.c	22 Sep 2019 16:19:53 -0000
@@ -75,6 +75,7 @@
 #include <sys/poll.h>
 #include <sys/file.h>
 #include <sys/disklabel.h>
+#include <sys/disk.h>
 #include <sys/lockf.h>
 #include <sys/tty.h>
 #include <sys/kauth.h>
@@ -366,10 +367,19 @@
 void
 spec_node_setmountedfs(vnode_t *devvp, struct mount *mp)
 {
+	struct dkwedge_info dkw;
 
 	KASSERT(devvp->v_type == VBLK);
 	KASSERT(devvp->v_specnode->sn_dev->sd_mountpoint == NULL || mp == NULL);
 	devvp->v_specnode->sn_dev->sd_mountpoint = mp;
+	if (mp == NULL)
+		return;
+
+	if (bdev_ioctl(devvp->v_rdev, DIOCGWEDGEINFO, &dkw, FREAD, curlwp) != 0)
+		return;
+
+	strlcpy(mp->mnt_stat.f_mntfromlabel, dkw.dkw_wname,
+	    sizeof(mp->mnt_stat.f_mntfromlabel));
 }
 
 /*

And I do understand how much code is needed for compat:

Legend:

+ required change
- autogenerated file

The rest are because of compat and glue.

christos

+ M bin/df/df.c
  M lib/libc/shlib_version
  M lib/libc/compat/gen/Makefile.inc
  A lib/libc/compat/gen/compat___getmntinfo13.c
  M lib/libc/compat/gen/compat_opendir.c
  M lib/libc/compat/sys/Makefile.inc
  A lib/libc/compat/sys/compat___fhstatvfs140.c
  A lib/libc/compat/sys/compat___fhstatvfs40.c
  M lib/libc/compat/sys/compat_fhstatvfs.c
  M lib/libc/compat/sys/compat_fhstatvfs1.c
  M lib/libc/compat/sys/compat_statfs.c
  A lib/libc/compat/sys/compat_statvfs.c
  M lib/libc/include/namespace.h
  M lib/libc/sys/Makefile.inc
  M lib/libc/sys/statvfs.c
  A sys/compat/common/compat_90_mod.c
  M sys/compat/common/compat_mod.h
  M sys/compat/common/files.common
  M sys/compat/common/vfs_syscalls_20.c
  M sys/compat/common/vfs_syscalls_30.c
  A sys/compat/common/vfs_syscalls_90.c
  M sys/compat/netbsd32/files.netbsd32
  M sys/compat/netbsd32/netbsd32.h
  A sys/compat/netbsd32/netbsd32_compat_90.c
  M sys/compat/netbsd32/netbsd32_conv.h
  M sys/compat/netbsd32/netbsd32_fs.c
- M sys/compat/netbsd32/netbsd32_syscall.h
- M sys/compat/netbsd32/netbsd32_syscallargs.h
- M sys/compat/netbsd32/netbsd32_syscalls.c
- M sys/compat/netbsd32/netbsd32_syscalls_autoload.c
- M sys/compat/netbsd32/netbsd32_sysent.c
- M sys/compat/netbsd32/netbsd32_systrace_args.c
  M sys/compat/netbsd32/syscalls.conf
  M sys/compat/netbsd32/syscalls.master
  A sys/conf/compat_netbsd90.config
  M sys/conf/files
- M sys/kern/init_sysent.c
- M sys/kern/syscalls.c
- M sys/kern/syscalls.conf
- M sys/kern/syscalls.master
- M sys/kern/syscalls_autoload.c
- M sys/kern/systrace_args.c
+ M sys/kern/vfs_subr.c
- M sys/kern/vfs_syscalls.c
+ M sys/miscfs/specfs/spec_vnops.c
  M sys/modules/Makefile
  A sys/modules/compat_90/Makefile
  A sys/modules/compat_netbsd32_90/Makefile
- M sys/rump/rump.sysmap
- M sys/rump/include/rump/rump_syscalls.h
- M sys/rump/librump/rumpkern/rump_syscalls.c
- M sys/rump/librump/rumpkern/rumpkern_syscalls.c
- M sys/rump/librump/rumpnet/rumpnet_syscalls.c
- M sys/rump/librump/rumpvfs/rumpvfs_syscalls.c
  M sys/sys/param.h
+ M sys/sys/statvfs.h
- M sys/sys/syscall.h
- M sys/sys/syscallargs.h



Home | Main Index | Thread Index | Old Index