[RFC] Teaching mount(8) to use nmount()

Pawel Jakub Dawidek pjd at FreeBSD.org
Sat Oct 8 23:52:59 PDT 2005


On Fri, Oct 07, 2005 at 10:46:20PM -0400, Craig Rodrigues wrote:
+> I would appreciate any comments on the attached patch. 

I haven't has chance to run any tests, as I'm not at home, so I just
reviewed the patch a bit.

+> +static void
+> +usage(void)
+> +{
+> +	(void)fprintf(stderr,
+> +		"usage: mount_xfs [-t fstype] [-o options] target_fs mount_point\n");

mount_xfs is probably a typo here:)

+> +	printf("argc is: %d\n", argc); for (i=0; i < argc; ++i) { printf("%d: %s\n", argc, argv[i]); }

You probably want to remove it before committing.

+> +	optind = optreset = 1;		/* Reset for parse of new argv. */
+> +	while ((ch = getopt(argc, argv, "o:")) != -1) {
+> +		switch(ch) {
+> +		case 'o':
+> +			getmntopts(optarg, mopts, &mntflags, 0);
+> +			p = strchr(optarg, '=');
+> +			val = "";
+> +			if (p != NULL) {
+> +				*p = '\0';
+> +				val = p + 1;
+> +			}
+> +			build_iovec(&iov, &iovlen, optarg, val, -1);
+> +			break;

Ok, as I suggested on IRC, this can handle only options given in form
'-o opt1 -o opt2 -o opt3', but not '-o opt1,opt2,opt3'.

+> +	printf("argc is: %d\n", argc);

Another debug printf.


I think it is a step forward, so I'm not against committing it, but we need
to design it better at the end.

My suggestion (which I discusses with Craig on IRC a bit already) is as
follows:

- We create one mount(8) program.

- When it is called with '-t <fs>' switch, we look for
  /lib/mount/mount_<fs>.so and try to dlopen() it.

- When there is no such .so, we just pass all option via nmount() to the
  kernel.

- When there is .so, we decided based on things found there which options
  needs special treatment (like '-C' for mount_cd9660, etc.). Options
  which are not defined in .so we pass to the kernel without touching.

The advantages:

- No more external executables for every single file system.
- mount(8) doesn't have to know about any specific FS, we can just add
  mount_<fs>.so if needed dinamically.
- We need to create .so only for file systems for which some work has to
  be done in userland.
- Passing options via nmount(2) as strings should allow to remove this
  annoying behaviour:

	# mount
	...
	/dev/md0 on /mnt/tmp (ufs, local, noatime, noexec, read-only)
	# mount -u -o rw /mnt/tmp
	# mount
	...
	/dev/md0 on /mnt/tmp (ufs, local)

  'noexec' and 'noatime' are gone. I know that I can use 'current', but this
  doesn't seem to be intuitive for me (I think not only for me, but I can be
  wrong:)).

Comments are welcome.

-- 
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20051009/a7ef85ae/attachment.bin


More information about the freebsd-arch mailing list