1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "@(#)fslib.c 1.25 05/06/08 SMI"
28
29 #include <stdio.h>
30 #include <stdarg.h>
31 #include <stdlib.h>
32 #include <unistd.h>
33 #include <libintl.h>
34 #include <string.h>
35 #include <fcntl.h>
36 #include <errno.h>
37 #include <syslog.h>
38 #include <alloca.h>
39 #include <sys/vfstab.h>
40 #include <sys/mnttab.h>
41 #include <sys/mntent.h>
42 #include <sys/mount.h>
43 #include <sys/filio.h>
44 #include <sys/fs/ufs_filio.h>
45 #include <sys/stat.h>
46 #include <sys/param.h>
47 #include <zone.h>
304
305 if (requested_opts == NULL)
306 return;
307
308 bufp = alloca(strlen(actual_opts) + 1);
309
310 while (*requested_opts != '\0') {
311 (void) getsubopt(&requested_opts, empty_opt_vector,
312 &option_ptr);
313
314 /*
315 * Truncate any "=<value>" string from the end of
316 * the option.
317 */
318 if ((equalptr = strchr(option_ptr, '=')) != NULL)
319 *equalptr = '\0';
320
321 if (*option_ptr == '\0')
322 continue;
323
324 /*
325 * Search for the requested option in the list of options
326 * actually supported.
327 */
328 found = 0;
329
330 /*
331 * Need to use a copy of actual_opts because getsubopt
332 * is destructive and we need to scan the actual_opts
333 * string more than once.
334 *
335 * We also need to reset actual_opt_hold to the
336 * beginning of the buffer because getsubopt changes
337 * actual_opt_hold (the pointer).
338 */
339 actual_opt_hold = bufp;
340 if (actual_opts != NULL)
341 (void) strcpy(actual_opt_hold, actual_opts);
342 else
343 *actual_opt_hold = '\0';
|
1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "@(#)fslib.c 1.26 08/05/07 SMI"
27
28 #include <stdio.h>
29 #include <stdarg.h>
30 #include <stdlib.h>
31 #include <unistd.h>
32 #include <libintl.h>
33 #include <string.h>
34 #include <fcntl.h>
35 #include <errno.h>
36 #include <syslog.h>
37 #include <alloca.h>
38 #include <sys/vfstab.h>
39 #include <sys/mnttab.h>
40 #include <sys/mntent.h>
41 #include <sys/mount.h>
42 #include <sys/filio.h>
43 #include <sys/fs/ufs_filio.h>
44 #include <sys/stat.h>
45 #include <sys/param.h>
46 #include <zone.h>
303
304 if (requested_opts == NULL)
305 return;
306
307 bufp = alloca(strlen(actual_opts) + 1);
308
309 while (*requested_opts != '\0') {
310 (void) getsubopt(&requested_opts, empty_opt_vector,
311 &option_ptr);
312
313 /*
314 * Truncate any "=<value>" string from the end of
315 * the option.
316 */
317 if ((equalptr = strchr(option_ptr, '=')) != NULL)
318 *equalptr = '\0';
319
320 if (*option_ptr == '\0')
321 continue;
322
323 /*
324 * Whilst we don't need this option to perform a lofi
325 * mount, let's not be mendacious enough to complain
326 * about it.
327 */
328 if (strcmp(option_ptr, "loop") == 0)
329 continue;
330
331 /*
332 * Search for the requested option in the list of options
333 * actually supported.
334 */
335 found = 0;
336
337 /*
338 * Need to use a copy of actual_opts because getsubopt
339 * is destructive and we need to scan the actual_opts
340 * string more than once.
341 *
342 * We also need to reset actual_opt_hold to the
343 * beginning of the buffer because getsubopt changes
344 * actual_opt_hold (the pointer).
345 */
346 actual_opt_hold = bufp;
347 if (actual_opts != NULL)
348 (void) strcpy(actual_opt_hold, actual_opts);
349 else
350 *actual_opt_hold = '\0';
|