bin/116980: [patch] [msdosfs] mount_msdosfs(8) resets some flags for 'update' mount

EugeneGrosbein at grosbein.pp.ru EugeneGrosbein at grosbein.pp.ru
Sun Oct 14 07:50:06 PDT 2007


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

From: EugeneGrosbein at grosbein.pp.ru
To: bug-followup at freebsd.org
Cc:  
Subject: Re: bin/116980: [patch] [msdosfs] mount_msdosfs(8) resets some flags for 'update' mount
Date: Sun, 14 Oct 2007 22:48:55 +0800

 Hi!
 
 Same patch, suitable for 7.0-PRERELEASE:
 
 --- sbin/mount_msdosfs/mount_msdosfs.c.orig	2007-01-29 08:49:08.000000000 +0700
 +++ sbin/mount_msdosfs/mount_msdosfs.c	2007-10-14 18:37:08.000000000 +0800
 @@ -69,7 +69,7 @@
  	struct iovec *iov = NULL;
  	int iovlen = 0;
  	struct stat sb;
 -	int c, mntflags, set_gid, set_uid, set_mask, set_dirmask;
 +	int c, mntflags, set_gid, set_uid, set_mask, set_dirmask, update = 0;
  	char *dev, *dir, mntpath[MAXPATHLEN], *csp;
  	char fstype[] = "msdosfs";
  	char errmsg[255] = {0};
 @@ -134,6 +134,7 @@
  				*p = '\0';
  				val = p + 1;
  			}
 +			update = update || !strcmp(optarg, "update");
  			build_iovec(&iov, &iovlen, optarg, val, (size_t)-1);
  			}
  			break;
 @@ -166,13 +167,15 @@
  	if (optind + 2 != argc)
  		usage();
  
 -	if (set_mask && !set_dirmask) {
 -		dirmask = mask;
 -		set_dirmask = 1;
 -	}
 -	else if (set_dirmask && !set_mask) {
 -		mask = dirmask;
 -		set_mask = 1;
 +	if (!update) {
 +		if (set_mask && !set_dirmask) {
 +			dirmask = mask;
 +			set_dirmask = 1;
 +		}
 +		else if (set_dirmask && !set_mask) {
 +			mask = dirmask;
 +			set_mask = 1;
 +		}
  	}
  
  	dev = argv[optind];
 @@ -196,27 +199,37 @@
  	(void)checkpath(dir, mntpath);
  	(void)rmslashes(dev, dev);
  
 -	if (!set_gid || !set_uid || !set_mask) {
 + 	if (!update && (!set_gid || !set_uid || !set_mask)) {
  		if (stat(mntpath, &sb) == -1)
  			err(EX_OSERR, "stat %s", mntpath);
 -
 -		if (!set_uid)
 + 		if (!set_uid) {
  			uid = sb.st_uid;
 -		if (!set_gid)
 + 			set_uid = 1;
 + 		}
 + 		if (!set_gid) {
  			gid = sb.st_gid;
 -		if (!set_mask)
 + 			set_gid = 1;
 + 		}
 + 		if (!set_mask) {
  			mask = dirmask =
  				sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
 + 			set_mask = set_dirmask = 1;
 + 		}
  	}
  
  	build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1);
  	build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1);
  	build_iovec(&iov, &iovlen, "from", dev, (size_t)-1);
  	build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg));
 -	build_iovec_argf(&iov, &iovlen, "uid", "%d", uid);
 -	build_iovec_argf(&iov, &iovlen, "gid", "%u", gid);
 -	build_iovec_argf(&iov, &iovlen, "mask", "%u", mask);
 -	build_iovec_argf(&iov, &iovlen, "dirmask", "%u", dirmask);
 +
 + 	if (set_uid)
 + 		build_iovec_argf(&iov, &iovlen, "uid", "%d", uid);
 + 	if (set_gid)
 + 		build_iovec_argf(&iov, &iovlen, "gid", "%u", gid);
 + 	if (set_mask)
 + 		build_iovec_argf(&iov, &iovlen, "mask", "%u", mask);
 + 	if (set_dirmask)
 + 		build_iovec_argf(&iov, &iovlen, "dirmask", "%u", dirmask);
  
  	if (nmount(iov, iovlen, mntflags) < 0)
  		err(1, "%s: %s", dev, errmsg);


More information about the freebsd-bugs mailing list