Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jan 2003 14:15:06 -0800
From:      Tim Kientzle <kientzle@acm.org>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   Ugly mount argv[0] trickery
Message-ID:  <3E31BAEA.7000500@acm.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------020100050001020302010807
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

The attached patch eliminates a bit of
unnecessary cleverness from 'mount.' If
someone would do me the favor of committing
this, I would greatly appreciate it.

Namely, some mount_XXX helpers support
multiple filesystem types and therefore
must consider argv[0].  For no apparent
reason, mount puts the filesystem
type (e.g., 'nfs') into argv[0] rather
than the executable name (e.g., 'mount_nfs').

This is unnecessary, counter-intuitive,
and also makes it rather ugly to put
'mount' into a crunchgen binary. ;-)

Tim Kientzle

--------------020100050001020302010807
Content-Type: text/plain;
 name="kientzle_mount.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="kientzle_mount.diff"

Index: mount.c
===================================================================
RCS file: /mnt/cvs/src/sbin/mount/mount.c,v
retrieving revision 1.50
diff -c -r1.50 mount.c
*** mount.c	14 Oct 2002 19:40:00 -0000	1.50
--- mount.c	24 Jan 2003 21:47:00 -0000
***************
*** 400,405 ****
--- 400,406 ----
  	pid_t pid;
  	int argc, i, status;
  	char *optbuf, execname[MAXPATHLEN + 1], mntpath[MAXPATHLEN];
+ 	char progname[MAXPATHLEN+1];
  
  #if __GNUC__
  	(void)&optbuf;
***************
*** 441,448 ****
  	if (strcmp(vfstype, "msdos") == 0)
  		vfstype = "msdosfs";
  
  	argc = 0;
! 	argv[argc++] = vfstype;
  	mangle(optbuf, &argc, argv);
  	argv[argc++] = spec;
  	argv[argc++] = name;
--- 442,451 ----
  	if (strcmp(vfstype, "msdos") == 0)
  		vfstype = "msdosfs";
  
+ 	snprintf(progname,sizeof(progname),"mount_%s",vfstype);
+ 
  	argc = 0;
! 	argv[argc++] = progname;
  	mangle(optbuf, &argc, argv);
  	argv[argc++] = spec;
  	argv[argc++] = name;

--------------020100050001020302010807--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E31BAEA.7000500>