Home | History | Annotate | Line # | Download | only in mount_msdos
mount_msdos.c revision 1.5
      1  1.1      cgd /*
      2  1.5      cgd  * Copyright (c) 1994 Christopher G. Demetriou
      3  1.5      cgd  * All rights reserved.
      4  1.5      cgd  *
      5  1.5      cgd  * Redistribution and use in source and binary forms, with or without
      6  1.5      cgd  * modification, are permitted provided that the following conditions
      7  1.5      cgd  * are met:
      8  1.5      cgd  * 1. Redistributions of source code must retain the above copyright
      9  1.5      cgd  *    notice, this list of conditions and the following disclaimer.
     10  1.5      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.5      cgd  *    notice, this list of conditions and the following disclaimer in the
     12  1.5      cgd  *    documentation and/or other materials provided with the distribution.
     13  1.5      cgd  * 3. All advertising materials mentioning features or use of this software
     14  1.5      cgd  *    must display the following acknowledgement:
     15  1.5      cgd  *      This product includes software developed by Christopher G. Demetriou.
     16  1.5      cgd  * 4. The name of the author may not be used to endorse or promote products
     17  1.5      cgd  *    derived from this software without specific prior written permission
     18  1.5      cgd  *
     19  1.5      cgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20  1.5      cgd  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21  1.5      cgd  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22  1.5      cgd  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23  1.5      cgd  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24  1.5      cgd  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  1.5      cgd  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  1.5      cgd  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  1.5      cgd  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28  1.5      cgd  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  1.1      cgd  */
     30  1.2  mycroft 
     31  1.2  mycroft #ifndef lint
     32  1.5      cgd static char rcsid[] = "$Id: mount_msdos.c,v 1.5 1994/04/07 02:31:22 cgd Exp $";
     33  1.2  mycroft #endif /* not lint */
     34  1.2  mycroft 
     35  1.1      cgd #include <sys/types.h>
     36  1.1      cgd #include <sys/mount.h>
     37  1.5      cgd #include <stdio.h>
     38  1.5      cgd #include <stdlib.h>
     39  1.5      cgd #include <string.h>
     40  1.1      cgd 
     41  1.1      cgd char *progname;
     42  1.1      cgd 
     43  1.1      cgd void
     44  1.1      cgd usage ()
     45  1.1      cgd {
     46  1.1      cgd 	fprintf (stderr, "usage: %s bdev dir\n", progname);
     47  1.1      cgd 	exit (1);
     48  1.1      cgd }
     49  1.1      cgd 
     50  1.1      cgd int
     51  1.1      cgd main (argc, argv)
     52  1.1      cgd int argc;
     53  1.1      cgd char **argv;
     54  1.1      cgd {
     55  1.1      cgd 	char *dev;
     56  1.1      cgd 	char *dir;
     57  1.3  mycroft 	struct msdosfs_args args;
     58  1.1      cgd 	int c;
     59  1.1      cgd 	extern char *optarg;
     60  1.1      cgd 	extern int optind;
     61  1.1      cgd 	int opts;
     62  1.1      cgd 
     63  1.1      cgd 	progname = argv[0];
     64  1.1      cgd 
     65  1.1      cgd 	opts = 0;
     66  1.1      cgd 
     67  1.1      cgd 	while ((c = getopt (argc, argv, "F:")) != EOF) {
     68  1.1      cgd 		switch (c) {
     69  1.1      cgd 		case 'F':
     70  1.1      cgd 			opts |= atoi (optarg);
     71  1.1      cgd 			break;
     72  1.1      cgd 		default:
     73  1.1      cgd 			usage ();
     74  1.1      cgd 		}
     75  1.1      cgd 	}
     76  1.1      cgd 
     77  1.1      cgd 	if (optind + 2 != argc)
     78  1.1      cgd 		usage ();
     79  1.1      cgd 
     80  1.1      cgd 	dev = argv[optind];
     81  1.1      cgd 	dir = argv[optind + 1];
     82  1.1      cgd 
     83  1.5      cgd 	(void)memset(&args, '\0', sizeof(args));
     84  1.1      cgd 	args.fspec = dev;
     85  1.1      cgd 
     86  1.1      cgd 	if (mount (MOUNT_MSDOS, dir, opts, &args) < 0) {
     87  1.1      cgd 		perror ("mount");
     88  1.1      cgd 		exit (1);
     89  1.1      cgd 	}
     90  1.1      cgd 
     91  1.1      cgd 	exit (0);
     92  1.1      cgd }
     93