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
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]
23 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * Portions of this source code were derived from Berkeley 4.3 BSD
32 * under license from the Regents of the University of California.
35 #pragma ident "%Z%%M% %I% %E% SMI"
37 #include <sys/types.h>
38 #include <sys/t_lock.h>
39 #include <sys/param.h>
40 #include <sys/errno.h>
41 #include <sys/fstyp.h>
42 #include <sys/systm.h>
43 #include <sys/mount.h>
45 #include <sys/vnode.h>
46 #include <sys/cmn_err.h>
48 #include <sys/debug.h>
49 #include <sys/pathname.h>
52 * System call to map fstype numbers to names, and vice versa.
55 static int sysfsind(char *);
56 static int sysfstyp(int, char *);
59 sysfs(int opcode
, long a1
, long a2
)
65 error
= sysfsind((char *)a1
);
68 error
= sysfstyp((int)a1
, (char *)a2
);
72 * Return number of fstypes configured in the system.
76 error
= set_errno(EINVAL
);
83 sysfsind(char *fsname
)
86 * Translate fs identifier to an index into the vfssw structure.
93 retval
= copyinstr(fsname
, fsbuf
, FSTYPSZ
, &len
);
94 if (retval
== ENOENT
) /* XXX */
95 retval
= EINVAL
; /* XXX */
96 if (len
== 1) /* Includes null byte */
99 return (set_errno(retval
));
101 * Search the vfssw table for the fs identifier
102 * and return the index.
104 if ((vswp
= vfs_getvfssw(fsbuf
)) != NULL
) {
105 retval
= vswp
- vfssw
;
106 vfs_unrefvfssw(vswp
);
110 return (set_errno(EINVAL
));
114 sysfstyp(int index
, char *cbuf
)
117 * Translate fstype index into an fs identifier.
124 if (index
<= 0 || index
>= nfstype
)
125 return (set_errno(EINVAL
));
127 vswp
= &vfssw
[index
];
129 osrc
= src
= vswp
->vsw_name
;
133 if (copyout(osrc
, cbuf
, src
- osrc
))
134 error
= set_errno(EFAULT
);