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>

index | next in thread | raw e-mail

[-- Attachment #1 --]
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

[-- Attachment #2 --]
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;
help

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