Deleted Added
full compact
vfs_extattr.c (141149) vfs_extattr.c (141471)
1/*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/vfs_extattr.c 141149 2005-02-02 17:17:15Z jeff $");
38__FBSDID("$FreeBSD: head/sys/kern/vfs_extattr.c 141471 2005-02-07 18:44:55Z jhb $");
39
40#include "opt_compat.h"
41#include "opt_mac.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/bio.h>
46#include <sys/buf.h>

--- 169 unchanged lines hidden (view full) ---

216int
217statfs(td, uap)
218 struct thread *td;
219 register struct statfs_args /* {
220 char *path;
221 struct statfs *buf;
222 } */ *uap;
223{
39
40#include "opt_compat.h"
41#include "opt_mac.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/bio.h>
46#include <sys/buf.h>

--- 169 unchanged lines hidden (view full) ---

216int
217statfs(td, uap)
218 struct thread *td;
219 register struct statfs_args /* {
220 char *path;
221 struct statfs *buf;
222 } */ *uap;
223{
224 struct statfs sf;
225 int error;
226
227 error = kern_statfs(td, uap->path, UIO_USERSPACE, &sf);
228 if (error == 0)
229 error = copyout(&sf, uap->buf, sizeof(sf));
230 return (error);
231}
232
233int
234kern_statfs(struct thread *td, char *path, enum uio_seg pathseg,
235 struct statfs *buf)
236{
224 struct mount *mp;
225 struct statfs *sp, sb;
226 int error;
227 struct nameidata nd;
228
229 mtx_lock(&Giant);
237 struct mount *mp;
238 struct statfs *sp, sb;
239 int error;
240 struct nameidata nd;
241
242 mtx_lock(&Giant);
230 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
243 NDINIT(&nd, LOOKUP, FOLLOW, pathseg, path, td);
231 if ((error = namei(&nd)) != 0) {
232 mtx_unlock(&Giant);
233 return (error);
234 }
235 mp = nd.ni_vp->v_mount;
236 sp = &mp->mnt_stat;
237 NDFREE(&nd, NDF_ONLY_PNBUF);
238 vrele(nd.ni_vp);

--- 14 unchanged lines hidden (view full) ---

253 mtx_unlock(&Giant);
254 if (error)
255 return (error);
256 if (suser(td)) {
257 bcopy(sp, &sb, sizeof(sb));
258 sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
259 sp = &sb;
260 }
244 if ((error = namei(&nd)) != 0) {
245 mtx_unlock(&Giant);
246 return (error);
247 }
248 mp = nd.ni_vp->v_mount;
249 sp = &mp->mnt_stat;
250 NDFREE(&nd, NDF_ONLY_PNBUF);
251 vrele(nd.ni_vp);

--- 14 unchanged lines hidden (view full) ---

266 mtx_unlock(&Giant);
267 if (error)
268 return (error);
269 if (suser(td)) {
270 bcopy(sp, &sb, sizeof(sb));
271 sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
272 sp = &sb;
273 }
261 return (copyout(sp, uap->buf, sizeof(*sp)));
274 *buf = *sp;
275 return (0);
262}
263
264/*
265 * Get filesystem statistics.
266 */
267#ifndef _SYS_SYSPROTO_H_
268struct fstatfs_args {
269 int fd;
270 struct statfs *buf;
271};
272#endif
273int
274fstatfs(td, uap)
275 struct thread *td;
276 register struct fstatfs_args /* {
277 int fd;
278 struct statfs *buf;
279 } */ *uap;
280{
276}
277
278/*
279 * Get filesystem statistics.
280 */
281#ifndef _SYS_SYSPROTO_H_
282struct fstatfs_args {
283 int fd;
284 struct statfs *buf;
285};
286#endif
287int
288fstatfs(td, uap)
289 struct thread *td;
290 register struct fstatfs_args /* {
291 int fd;
292 struct statfs *buf;
293 } */ *uap;
294{
295 struct statfs sf;
296 int error;
297
298 error = kern_fstatfs(td, uap->fd, &sf);
299 if (error == 0)
300 error = copyout(&sf, uap->buf, sizeof(sf));
301 return (error);
302}
303
304int
305kern_fstatfs(struct thread *td, int fd, struct statfs *buf)
306{
281 struct file *fp;
282 struct mount *mp;
283 struct statfs *sp, sb;
284 int error;
285
307 struct file *fp;
308 struct mount *mp;
309 struct statfs *sp, sb;
310 int error;
311
286 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
312 if ((error = getvnode(td->td_proc->p_fd, fd, &fp)) != 0)
287 return (error);
288 mtx_lock(&Giant);
289 mp = fp->f_vnode->v_mount;
290 fdrop(fp, td);
291 if (mp == NULL) {
292 mtx_unlock(&Giant);
293 return (EBADF);
294 }

--- 15 unchanged lines hidden (view full) ---

310 mtx_unlock(&Giant);
311 if (error)
312 return (error);
313 if (suser(td)) {
314 bcopy(sp, &sb, sizeof(sb));
315 sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
316 sp = &sb;
317 }
313 return (error);
314 mtx_lock(&Giant);
315 mp = fp->f_vnode->v_mount;
316 fdrop(fp, td);
317 if (mp == NULL) {
318 mtx_unlock(&Giant);
319 return (EBADF);
320 }

--- 15 unchanged lines hidden (view full) ---

336 mtx_unlock(&Giant);
337 if (error)
338 return (error);
339 if (suser(td)) {
340 bcopy(sp, &sb, sizeof(sb));
341 sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
342 sp = &sb;
343 }
318 return (copyout(sp, uap->buf, sizeof(*sp)));
344 *buf = *sp;
345 return (0);
319}
320
321/*
322 * Get statistics on all filesystems.
323 */
324#ifndef _SYS_SYSPROTO_H_
325struct getfsstat_args {
326 struct statfs *buf;

--- 99 unchanged lines hidden (view full) ---

426int
427freebsd4_statfs(td, uap)
428 struct thread *td;
429 struct freebsd4_statfs_args /* {
430 char *path;
431 struct ostatfs *buf;
432 } */ *uap;
433{
346}
347
348/*
349 * Get statistics on all filesystems.
350 */
351#ifndef _SYS_SYSPROTO_H_
352struct getfsstat_args {
353 struct statfs *buf;

--- 99 unchanged lines hidden (view full) ---

453int
454freebsd4_statfs(td, uap)
455 struct thread *td;
456 struct freebsd4_statfs_args /* {
457 char *path;
458 struct ostatfs *buf;
459 } */ *uap;
460{
434 struct mount *mp;
435 struct statfs *sp;
436 struct ostatfs osb;
461 struct ostatfs osb;
462 struct statfs sf;
437 int error;
463 int error;
438 struct nameidata nd;
439
464
440 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
441 if ((error = namei(&nd)) != 0)
442 return (error);
443 mp = nd.ni_vp->v_mount;
444 sp = &mp->mnt_stat;
445 NDFREE(&nd, NDF_ONLY_PNBUF);
446 vrele(nd.ni_vp);
447#ifdef MAC
448 error = mac_check_mount_stat(td->td_ucred, mp);
465 error = kern_statfs(td, uap->path, UIO_USERSPACE, &sf);
449 if (error)
450 return (error);
466 if (error)
467 return (error);
451#endif
452 error = VFS_STATFS(mp, sp, td);
453 if (error)
454 return (error);
455 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
456 cvtstatfs(td, sp, &osb);
468 cvtstatfs(td, &sf, &osb);
457 return (copyout(&osb, uap->buf, sizeof(osb)));
458}
459
460/*
461 * Get filesystem statistics.
462 */
463#ifndef _SYS_SYSPROTO_H_
464struct freebsd4_fstatfs_args {

--- 4 unchanged lines hidden (view full) ---

469int
470freebsd4_fstatfs(td, uap)
471 struct thread *td;
472 struct freebsd4_fstatfs_args /* {
473 int fd;
474 struct ostatfs *buf;
475 } */ *uap;
476{
469 return (copyout(&osb, uap->buf, sizeof(osb)));
470}
471
472/*
473 * Get filesystem statistics.
474 */
475#ifndef _SYS_SYSPROTO_H_
476struct freebsd4_fstatfs_args {

--- 4 unchanged lines hidden (view full) ---

481int
482freebsd4_fstatfs(td, uap)
483 struct thread *td;
484 struct freebsd4_fstatfs_args /* {
485 int fd;
486 struct ostatfs *buf;
487 } */ *uap;
488{
477 struct file *fp;
478 struct mount *mp;
479 struct statfs *sp;
480 struct ostatfs osb;
489 struct ostatfs osb;
490 struct statfs sf;
481 int error;
482
491 int error;
492
483 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
484 return (error);
485 mp = fp->f_vnode->v_mount;
486 fdrop(fp, td);
487 if (mp == NULL)
488 return (EBADF);
489#ifdef MAC
490 error = mac_check_mount_stat(td->td_ucred, mp);
493 error = kern_fstatfs(td, uap->fd, &sf);
491 if (error)
492 return (error);
494 if (error)
495 return (error);
493#endif
494 sp = &mp->mnt_stat;
495 error = VFS_STATFS(mp, sp, td);
496 if (error)
497 return (error);
498 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
499 cvtstatfs(td, sp, &osb);
496 cvtstatfs(td, &sf, &osb);
500 return (copyout(&osb, uap->buf, sizeof(osb)));
501}
502
503/*
504 * Get statistics on all filesystems.
505 */
506#ifndef _SYS_SYSPROTO_H_
507struct freebsd4_getfsstat_args {

--- 85 unchanged lines hidden (view full) ---

593int
594freebsd4_fhstatfs(td, uap)
595 struct thread *td;
596 struct freebsd4_fhstatfs_args /* {
597 struct fhandle *u_fhp;
598 struct ostatfs *buf;
599 } */ *uap;
600{
497 return (copyout(&osb, uap->buf, sizeof(osb)));
498}
499
500/*
501 * Get statistics on all filesystems.
502 */
503#ifndef _SYS_SYSPROTO_H_
504struct freebsd4_getfsstat_args {

--- 85 unchanged lines hidden (view full) ---

590int
591freebsd4_fhstatfs(td, uap)
592 struct thread *td;
593 struct freebsd4_fhstatfs_args /* {
594 struct fhandle *u_fhp;
595 struct ostatfs *buf;
596 } */ *uap;
597{
601 struct statfs *sp;
602 struct mount *mp;
603 struct vnode *vp;
604 struct ostatfs osb;
598 struct ostatfs osb;
599 struct statfs sf;
605 fhandle_t fh;
606 int error;
607
600 fhandle_t fh;
601 int error;
602
608 error = suser(td);
609 if (error)
610 return (error);
611 if ((error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t))) != 0)
612 return (error);
603 if ((error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t))) != 0)
604 return (error);
613 if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL)
614 return (ESTALE);
615 if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp)))
616 return (error);
617 mp = vp->v_mount;
618 sp = &mp->mnt_stat;
619 vput(vp);
620#ifdef MAC
621 error = mac_check_mount_stat(td->td_ucred, mp);
605 error = kern_fhstatfs(td, fh, &sf);
622 if (error)
623 return (error);
606 if (error)
607 return (error);
624#endif
625 if ((error = VFS_STATFS(mp, sp, td)) != 0)
626 return (error);
627 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
628 cvtstatfs(td, sp, &osb);
608 cvtstatfs(td, &sf, &osb);
629 return (copyout(&osb, uap->buf, sizeof(osb)));
630}
631
632/*
633 * Convert a new format statfs structure to an old format statfs structure.
634 */
635static void
636cvtstatfs(td, nsp, osp)

--- 1330 unchanged lines hidden (view full) ---

1967 register struct ostat_args /* {
1968 char *path;
1969 struct ostat *ub;
1970 } */ *uap;
1971{
1972 struct stat sb;
1973 struct ostat osb;
1974 int error;
609 return (copyout(&osb, uap->buf, sizeof(osb)));
610}
611
612/*
613 * Convert a new format statfs structure to an old format statfs structure.
614 */
615static void
616cvtstatfs(td, nsp, osp)

--- 1330 unchanged lines hidden (view full) ---

1947 register struct ostat_args /* {
1948 char *path;
1949 struct ostat *ub;
1950 } */ *uap;
1951{
1952 struct stat sb;
1953 struct ostat osb;
1954 int error;
1975 struct nameidata nd;
1976
1955
1977 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
1978 uap->path, td);
1979 if ((error = namei(&nd)) != 0)
1980 return (error);
1981 NDFREE(&nd, NDF_ONLY_PNBUF);
1982 error = vn_stat(nd.ni_vp, &sb, td->td_ucred, NOCRED, td);
1983 vput(nd.ni_vp);
1956 error = kern_stat(td, uap->path, UIO_USERSPACE, &sb);
1984 if (error)
1985 return (error);
1986 cvtstat(&sb, &osb);
1987 error = copyout(&osb, uap->ub, sizeof (osb));
1988 return (error);
1989}
1990
1991/*

--- 8 unchanged lines hidden (view full) ---

2000int
2001olstat(td, uap)
2002 struct thread *td;
2003 register struct olstat_args /* {
2004 char *path;
2005 struct ostat *ub;
2006 } */ *uap;
2007{
1957 if (error)
1958 return (error);
1959 cvtstat(&sb, &osb);
1960 error = copyout(&osb, uap->ub, sizeof (osb));
1961 return (error);
1962}
1963
1964/*

--- 8 unchanged lines hidden (view full) ---

1973int
1974olstat(td, uap)
1975 struct thread *td;
1976 register struct olstat_args /* {
1977 char *path;
1978 struct ostat *ub;
1979 } */ *uap;
1980{
2008 struct vnode *vp;
2009 struct stat sb;
2010 struct ostat osb;
2011 int error;
1981 struct stat sb;
1982 struct ostat osb;
1983 int error;
2012 struct nameidata nd;
2013
1984
2014 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
2015 uap->path, td);
2016 if ((error = namei(&nd)) != 0)
2017 return (error);
2018 vp = nd.ni_vp;
2019 error = vn_stat(vp, &sb, td->td_ucred, NOCRED, td);
2020 NDFREE(&nd, NDF_ONLY_PNBUF);
2021 vput(vp);
1985 error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb);
2022 if (error)
2023 return (error);
2024 cvtstat(&sb, &osb);
2025 error = copyout(&osb, uap->ub, sizeof (osb));
2026 return (error);
2027}
2028
2029/*

--- 40 unchanged lines hidden (view full) ---

2070 struct thread *td;
2071 register struct stat_args /* {
2072 char *path;
2073 struct stat *ub;
2074 } */ *uap;
2075{
2076 struct stat sb;
2077 int error;
1986 if (error)
1987 return (error);
1988 cvtstat(&sb, &osb);
1989 error = copyout(&osb, uap->ub, sizeof (osb));
1990 return (error);
1991}
1992
1993/*

--- 40 unchanged lines hidden (view full) ---

2034 struct thread *td;
2035 register struct stat_args /* {
2036 char *path;
2037 struct stat *ub;
2038 } */ *uap;
2039{
2040 struct stat sb;
2041 int error;
2042
2043 error = kern_stat(td, uap->path, UIO_USERSPACE, &sb);
2044 if (error == 0)
2045 error = copyout(&sb, uap->ub, sizeof (sb));
2046 return (error);
2047}
2048
2049int
2050kern_stat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp)
2051{
2078 struct nameidata nd;
2052 struct nameidata nd;
2079 int vfslocked;
2053 struct stat sb;
2054 int error, vfslocked;
2080
2081#ifdef LOOKUP_SHARED
2082 NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | NOOBJ | MPSAFE,
2055
2056#ifdef LOOKUP_SHARED
2057 NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | NOOBJ | MPSAFE,
2083 UIO_USERSPACE, uap->path, td);
2058 pathseg, path, td);
2084#else
2059#else
2085 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ | MPSAFE, UIO_USERSPACE,
2086 uap->path, td);
2060 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ | MPSAFE, pathseg, path,
2061 td);
2087#endif
2088 if ((error = namei(&nd)) != 0)
2089 return (error);
2090 vfslocked = NDHASGIANT(&nd);
2091 error = vn_stat(nd.ni_vp, &sb, td->td_ucred, NOCRED, td);
2092 NDFREE(&nd, NDF_ONLY_PNBUF);
2093 vput(nd.ni_vp);
2094 VFS_UNLOCK_GIANT(vfslocked);
2095 if (error)
2096 return (error);
2062#endif
2063 if ((error = namei(&nd)) != 0)
2064 return (error);
2065 vfslocked = NDHASGIANT(&nd);
2066 error = vn_stat(nd.ni_vp, &sb, td->td_ucred, NOCRED, td);
2067 NDFREE(&nd, NDF_ONLY_PNBUF);
2068 vput(nd.ni_vp);
2069 VFS_UNLOCK_GIANT(vfslocked);
2070 if (error)
2071 return (error);
2097 error = copyout(&sb, uap->ub, sizeof (sb));
2098 return (error);
2072 *sbp = sb;
2073 return (0);
2099}
2100
2101/*
2102 * Get file status; this version does not follow links.
2103 */
2104#ifndef _SYS_SYSPROTO_H_
2105struct lstat_args {
2106 char *path;
2107 struct stat *ub;
2108};
2109#endif
2110int
2111lstat(td, uap)
2112 struct thread *td;
2113 register struct lstat_args /* {
2114 char *path;
2115 struct stat *ub;
2116 } */ *uap;
2117{
2074}
2075
2076/*
2077 * Get file status; this version does not follow links.
2078 */
2079#ifndef _SYS_SYSPROTO_H_
2080struct lstat_args {
2081 char *path;
2082 struct stat *ub;
2083};
2084#endif
2085int
2086lstat(td, uap)
2087 struct thread *td;
2088 register struct lstat_args /* {
2089 char *path;
2090 struct stat *ub;
2091 } */ *uap;
2092{
2093 struct stat sb;
2118 int error;
2094 int error;
2095
2096 error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb);
2097 if (error == 0)
2098 error = copyout(&sb, uap->ub, sizeof (sb));
2099 return (error);
2100}
2101
2102int
2103kern_lstat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp)
2104{
2119 struct vnode *vp;
2120 struct stat sb;
2121 struct nameidata nd;
2105 struct vnode *vp;
2106 struct stat sb;
2107 struct nameidata nd;
2122 int vfslocked;
2108 int error, vfslocked;
2123
2109
2110 /* XXX LOOKUP_SHARED? */
2124 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ | MPSAFE,
2111 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ | MPSAFE,
2125 UIO_USERSPACE, uap->path, td);
2112 pathseg, path, td);
2126 if ((error = namei(&nd)) != 0)
2127 return (error);
2128 vfslocked = NDHASGIANT(&nd);
2129 vp = nd.ni_vp;
2130 error = vn_stat(vp, &sb, td->td_ucred, NOCRED, td);
2131 NDFREE(&nd, NDF_ONLY_PNBUF);
2132 vput(vp);
2133 VFS_UNLOCK_GIANT(vfslocked);
2134 if (error)
2135 return (error);
2113 if ((error = namei(&nd)) != 0)
2114 return (error);
2115 vfslocked = NDHASGIANT(&nd);
2116 vp = nd.ni_vp;
2117 error = vn_stat(vp, &sb, td->td_ucred, NOCRED, td);
2118 NDFREE(&nd, NDF_ONLY_PNBUF);
2119 vput(vp);
2120 VFS_UNLOCK_GIANT(vfslocked);
2121 if (error)
2122 return (error);
2136 error = copyout(&sb, uap->ub, sizeof (sb));
2137 return (error);
2123 *sbp = sb;
2124 return (0);
2138}
2139
2140/*
2125}
2126
2127/*
2141 * Implementation of the NetBSD stat() function.
2142 * XXX This should probably be collapsed with the FreeBSD version,
2143 * as the differences are only due to vn_stat() clearing spares at
2144 * the end of the structures. vn_stat could be split to avoid this,
2145 * and thus collapse the following to close to zero code.
2128 * Implementation of the NetBSD [l]stat() functions.
2146 */
2147void
2148cvtnstat(sb, nsb)
2149 struct stat *sb;
2150 struct nstat *nsb;
2151{
2152 bzero(nsb, sizeof *nsb);
2153 nsb->st_dev = sb->st_dev;

--- 26 unchanged lines hidden (view full) ---

2180 register struct nstat_args /* {
2181 char *path;
2182 struct nstat *ub;
2183 } */ *uap;
2184{
2185 struct stat sb;
2186 struct nstat nsb;
2187 int error;
2129 */
2130void
2131cvtnstat(sb, nsb)
2132 struct stat *sb;
2133 struct nstat *nsb;
2134{
2135 bzero(nsb, sizeof *nsb);
2136 nsb->st_dev = sb->st_dev;

--- 26 unchanged lines hidden (view full) ---

2163 register struct nstat_args /* {
2164 char *path;
2165 struct nstat *ub;
2166 } */ *uap;
2167{
2168 struct stat sb;
2169 struct nstat nsb;
2170 int error;
2188 struct nameidata nd;
2189 int vfslocked;
2190
2171
2191 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ | MPSAFE, UIO_USERSPACE,
2192 uap->path, td);
2193 if ((error = namei(&nd)) != 0)
2194 return (error);
2195 vfslocked = NDHASGIANT(&nd);
2196 NDFREE(&nd, NDF_ONLY_PNBUF);
2197 error = vn_stat(nd.ni_vp, &sb, td->td_ucred, NOCRED, td);
2198 vput(nd.ni_vp);
2199 VFS_UNLOCK_GIANT(vfslocked);
2172 error = kern_stat(td, uap->path, UIO_USERSPACE, &sb);
2200 if (error)
2201 return (error);
2202 cvtnstat(&sb, &nsb);
2203 error = copyout(&nsb, uap->ub, sizeof (nsb));
2204 return (error);
2205}
2206
2207/*

--- 8 unchanged lines hidden (view full) ---

2216int
2217nlstat(td, uap)
2218 struct thread *td;
2219 register struct nlstat_args /* {
2220 char *path;
2221 struct nstat *ub;
2222 } */ *uap;
2223{
2173 if (error)
2174 return (error);
2175 cvtnstat(&sb, &nsb);
2176 error = copyout(&nsb, uap->ub, sizeof (nsb));
2177 return (error);
2178}
2179
2180/*

--- 8 unchanged lines hidden (view full) ---

2189int
2190nlstat(td, uap)
2191 struct thread *td;
2192 register struct nlstat_args /* {
2193 char *path;
2194 struct nstat *ub;
2195 } */ *uap;
2196{
2224 int error;
2225 struct vnode *vp;
2226 struct stat sb;
2227 struct nstat nsb;
2197 struct stat sb;
2198 struct nstat nsb;
2228 struct nameidata nd;
2229 int vfslocked;
2199 int error;
2230
2200
2231 NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ | MPSAFE,
2232 UIO_USERSPACE, uap->path, td);
2233 if ((error = namei(&nd)) != 0)
2234 return (error);
2235 vfslocked = NDHASGIANT(&nd);
2236 vp = nd.ni_vp;
2237 NDFREE(&nd, NDF_ONLY_PNBUF);
2238 error = vn_stat(vp, &sb, td->td_ucred, NOCRED, td);
2239 vput(vp);
2240 VFS_UNLOCK_GIANT(vfslocked);
2201 error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb);
2241 if (error)
2242 return (error);
2243 cvtnstat(&sb, &nsb);
2244 error = copyout(&nsb, uap->ub, sizeof (nsb));
2245 return (error);
2246}
2247
2248/*

--- 1980 unchanged lines hidden (view full) ---

4229int
4230fhstatfs(td, uap)
4231 struct thread *td;
4232 struct fhstatfs_args /* {
4233 struct fhandle *u_fhp;
4234 struct statfs *buf;
4235 } */ *uap;
4236{
2202 if (error)
2203 return (error);
2204 cvtnstat(&sb, &nsb);
2205 error = copyout(&nsb, uap->ub, sizeof (nsb));
2206 return (error);
2207}
2208
2209/*

--- 1980 unchanged lines hidden (view full) ---

4190int
4191fhstatfs(td, uap)
4192 struct thread *td;
4193 struct fhstatfs_args /* {
4194 struct fhandle *u_fhp;
4195 struct statfs *buf;
4196 } */ *uap;
4197{
4198 struct statfs sf;
4199 fhandle_t fh;
4200 int error;
4201
4202 if ((error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t))) != 0)
4203 return (error);
4204 error = kern_fhstatfs(td, fh, &sf);
4205 if (error == 0)
4206 error = copyout(&sf, uap->buf, sizeof(sf));
4207 return (error);
4208}
4209
4210int
4211kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf)
4212{
4237 struct statfs *sp;
4238 struct mount *mp;
4239 struct vnode *vp;
4213 struct statfs *sp;
4214 struct mount *mp;
4215 struct vnode *vp;
4240 fhandle_t fh;
4241 int error;
4242
4243 error = suser(td);
4244 if (error)
4245 return (error);
4216 int error;
4217
4218 error = suser(td);
4219 if (error)
4220 return (error);
4246 if ((error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t))) != 0)
4247 return (error);
4248 if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL)
4249 return (ESTALE);
4250 if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp)))
4251 return (error);
4252 mp = vp->v_mount;
4253 sp = &mp->mnt_stat;
4254 vput(vp);
4255#ifdef MAC

--- 4 unchanged lines hidden (view full) ---

4260 /*
4261 * Set these in case the underlying filesystem fails to do so.
4262 */
4263 sp->f_version = STATFS_VERSION;
4264 sp->f_namemax = NAME_MAX;
4265 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
4266 if ((error = VFS_STATFS(mp, sp, td)) != 0)
4267 return (error);
4221 if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL)
4222 return (ESTALE);
4223 if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp)))
4224 return (error);
4225 mp = vp->v_mount;
4226 sp = &mp->mnt_stat;
4227 vput(vp);
4228#ifdef MAC

--- 4 unchanged lines hidden (view full) ---

4233 /*
4234 * Set these in case the underlying filesystem fails to do so.
4235 */
4236 sp->f_version = STATFS_VERSION;
4237 sp->f_namemax = NAME_MAX;
4238 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
4239 if ((error = VFS_STATFS(mp, sp, td)) != 0)
4240 return (error);
4268 return (copyout(sp, uap->buf, sizeof(*sp)));
4241 *buf = *sp;
4242 return (0);
4269}
4270
4271/*
4272 * Syscall to push extended attribute configuration information into the
4273 * VFS. Accepts a path, which it converts to a mountpoint, as well as
4274 * a command (int cmd), and attribute name and misc data. For now, the
4275 * attribute name is left in userspace for consumption by the VFS_op.
4276 * It will probably be changed to be copied into sysspace by the

--- 662 unchanged lines hidden ---
4243}
4244
4245/*
4246 * Syscall to push extended attribute configuration information into the
4247 * VFS. Accepts a path, which it converts to a mountpoint, as well as
4248 * a command (int cmd), and attribute name and misc data. For now, the
4249 * attribute name is left in userspace for consumption by the VFS_op.
4250 * It will probably be changed to be copied into sysspace by the

--- 662 unchanged lines hidden ---