6253 F_GETLK doesn't always return lock owner
[illumos-gate.git] / usr / src / cmd / fs.d / deffs.c
blobace3f9beb539a51c2354dfc468110ad63bd11eb9
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990, 1991, 1997 SMI */
23 /* All Rights Reserved */
25 #ident "%Z%%M% %I% %E% SMI"
27 #include <stdio.h>
28 #include <deflt.h>
29 #include <string.h>
31 #define LOCAL "/etc/default/fs"
32 #define REMOTE "/etc/dfs/fstypes"
35 * This is used to figure out the default file system type if "-F FStype"
36 * is not specified with the file system command and no entry in the
37 * /etc/vfstab matches the specified special.
38 * If the first character of the "special" is a "/" (eg, "/dev/dsk/c0d1s2"),
39 * returns the default local filesystem type.
40 * Otherwise (eg, "server:/path/name" or "resource"), returns the default
41 * remote filesystem type.
43 char *
44 default_fstype(char *special)
46 char *deffs;
47 static char buf[BUFSIZ];
48 FILE *fp;
50 if (*special == '/') {
51 if (defopen(LOCAL) != 0)
52 return ("ufs");
53 else {
54 if ((deffs = defread("LOCAL=")) == NULL) {
55 defopen(NULL); /* close default file */
56 return ("ufs");
57 } else {
58 defopen(NULL); /* close default file */
59 return (deffs);
62 } else {
63 if ((fp = fopen(REMOTE, "r")) == NULL)
64 return ("nfs");
65 else {
66 if (fgets(buf, sizeof (buf), fp) == NULL) {
67 fclose(fp);
68 return ("nfs");
69 } else {
70 deffs = strtok(buf, " \t\n");
71 fclose(fp);
72 return (deffs);