bin/120784: [patch] mount(8): allow mount from fstab with 3rd party tools like ntfs-3g

Dominic Fandrey kamikaze at bsdforen.de
Wed Feb 20 11:20:04 UTC 2008


The following reply was made to PR bin/120784; it has been noted by GNATS.

From: Dominic Fandrey <kamikaze at bsdforen.de>
To: bug-followup at FreeBSD.org, kamikaze at bsdforen.de
Cc:  
Subject: Re: bin/120784: [patch] mount(8): allow mount from fstab with 3rd
 party tools like ntfs-3g
Date: Wed, 20 Feb 2008 12:17:25 +0100

 This is an alternative patch I have sent to Remko Lodder. It probably should 
 be available here, too.
 
 This one also gets rid of the use_mountprog() stuff, since things simply 
 work automatically due to the fallback. The previous version of the patch 
 was targeted at touching as few lines as possible.
 
 This one is meant to be as clean as I can make it. I prefer it, but both 
 versions work and a more conservative mind might prefer the previous patch.
 
 
 
 diff -Pur sbin/mount.orig/mount.c sbin/mount/mount.c
 --- sbin/mount.orig/mount.c	2008-02-18 19:44:05.000000000 +0100
 +++ sbin/mount/mount.c	2008-02-19 19:02:43.000000000 +0100
 @@ -126,28 +126,6 @@
   static const char groupquotaeq[] = "groupquota=";
 
   static int
 -use_mountprog(const char *vfstype)
 -{
 -	/* XXX: We need to get away from implementing external mount
 -	 *      programs for every filesystem, and move towards having
 -	 *	each filesystem properly implement the nmount() system call.
 -	 */
 -	unsigned int i;
 -	const char *fs[] = {
 -	"cd9660", "mfs", "msdosfs", "nfs", "nfs4", "ntfs",
 -	"nwfs", "nullfs", "portalfs", "smbfs", "udf", "unionfs",
 -	NULL
 -	};
 -
 -	for (i = 0; fs[i] != NULL; ++i) {
 -		if (strcmp(vfstype, fs[i]) == 0)
 -			return (1);
 -	}
 -	
 -	return (0);
 -}
 -
 -static int
   exec_mountprog(const char *name, const char *execname, char *const argv[])
   {
   	pid_t pid;
 @@ -547,20 +525,18 @@
   	argv[argc] = NULL;
 
   	if (debug) {
 -		if (use_mountprog(vfstype))
 -			printf("exec: mount_%s", vfstype);
 -		else
 -			printf("mount -t %s", vfstype);
 +		printf("mount -t %s", vfstype);
   		for (i = 1; i < argc; i++)
   			(void)printf(" %s", argv[i]);
   		(void)printf("\n");
   		return (0);
   	}
 
 -	if (use_mountprog(vfstype)) {
 +	ret = mount_fs(vfstype, argc, argv);
 +	if (ret < 0) {
 +		if (verbose)
 +			warn("falling back to old style mount");
   		ret = exec_mountprog(name, execname, argv);
 -	} else {
 -		ret = mount_fs(vfstype, argc, argv);
   	}
 
   	free(optbuf);
 diff -Pur sbin/mount.orig/mount_fs.c sbin/mount/mount_fs.c
 --- sbin/mount.orig/mount_fs.c	2008-02-18 19:44:05.000000000 +0100
 +++ sbin/mount/mount_fs.c	2008-02-18 19:44:37.000000000 +0100
 @@ -107,6 +107,11 @@
   				val = p + 1;
   			}
   			build_iovec(&iov, &iovlen, optarg, val, (size_t)-1);
 +			// Repair arguments, in case they are required when
 +			// falling back to the old style exec_mountprog.
 +			if (p != NULL) {
 +				*p = '=';
 +			}
   			break;
   		case '?':
   		default:
 @@ -131,8 +136,6 @@
   	build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg));
   	
   	ret = nmount(iov, iovlen, mntflags);
 -	if (ret < 0)
 -		err(1, "%s %s", dev, errmsg);
 
   	return (ret);
   }


More information about the freebsd-bugs mailing list