| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: vfs_syscalls_50.c,v 1.14 2012/01/29 07:19:04 dholland Exp $ */ | | 1 | /* $NetBSD: vfs_syscalls_50.c,v 1.15 2012/01/29 07:19:48 dholland Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Christos Zoulas. | | 8 | * by Christos Zoulas. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -26,42 +26,41 @@ | | | @@ -26,42 +26,41 @@ |
26 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 26 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
27 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 27 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
28 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 28 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
30 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 30 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
36 | * POSSIBILITY OF SUCH DAMAGE. | | 36 | * POSSIBILITY OF SUCH DAMAGE. |
37 | */ | | 37 | */ |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.14 2012/01/29 07:19:04 dholland Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.15 2012/01/29 07:19:48 dholland Exp $"); |
40 | | | 40 | |
41 | #include <sys/param.h> | | 41 | #include <sys/param.h> |
42 | #include <sys/systm.h> | | 42 | #include <sys/systm.h> |
43 | #include <sys/namei.h> | | 43 | #include <sys/namei.h> |
44 | #include <sys/filedesc.h> | | 44 | #include <sys/filedesc.h> |
45 | #include <sys/kernel.h> | | 45 | #include <sys/kernel.h> |
46 | #include <sys/file.h> | | 46 | #include <sys/file.h> |
47 | #include <sys/stat.h> | | 47 | #include <sys/stat.h> |
48 | #include <sys/socketvar.h> | | 48 | #include <sys/socketvar.h> |
49 | #include <sys/vnode.h> | | 49 | #include <sys/vnode.h> |
50 | #include <sys/mount.h> | | 50 | #include <sys/mount.h> |
51 | #include <sys/proc.h> | | 51 | #include <sys/proc.h> |
52 | #include <sys/uio.h> | | 52 | #include <sys/uio.h> |
53 | #include <sys/dirent.h> | | 53 | #include <sys/dirent.h> |
54 | #include <sys/malloc.h> | | | |
55 | #include <sys/kauth.h> | | 54 | #include <sys/kauth.h> |
56 | #include <sys/time.h> | | 55 | #include <sys/time.h> |
57 | #include <sys/vfs_syscalls.h> | | 56 | #include <sys/vfs_syscalls.h> |
58 | #ifndef LFS | | 57 | #ifndef LFS |
59 | #define LFS | | 58 | #define LFS |
60 | #endif | | 59 | #endif |
61 | #include <sys/syscallargs.h> | | 60 | #include <sys/syscallargs.h> |
62 | | | 61 | |
63 | #include <ufs/lfs/lfs_extern.h> | | 62 | #include <ufs/lfs/lfs_extern.h> |
64 | | | 63 | |
65 | #include <sys/quota.h> | | 64 | #include <sys/quota.h> |
66 | #include <sys/quotactl.h> | | 65 | #include <sys/quotactl.h> |
67 | #include <ufs/ufs/quota1.h> | | 66 | #include <ufs/ufs/quota1.h> |
| @@ -317,61 +316,62 @@ compat_50_sys_mknod(struct lwp *l, | | | @@ -317,61 +316,62 @@ compat_50_sys_mknod(struct lwp *l, |
317 | SCARG(uap, dev), retval, UIO_USERSPACE); | | 316 | SCARG(uap, dev), retval, UIO_USERSPACE); |
318 | } | | 317 | } |
319 | | | 318 | |
320 | /* ARGSUSED */ | | 319 | /* ARGSUSED */ |
321 | int | | 320 | int |
322 | compat_50_sys_quotactl(struct lwp *l, const struct compat_50_sys_quotactl_args *uap, register_t *retval) | | 321 | compat_50_sys_quotactl(struct lwp *l, const struct compat_50_sys_quotactl_args *uap, register_t *retval) |
323 | { | | 322 | { |
324 | /* { | | 323 | /* { |
325 | syscallarg(const char *) path; | | 324 | syscallarg(const char *) path; |
326 | syscallarg(int) cmd; | | 325 | syscallarg(int) cmd; |
327 | syscallarg(int) uid; | | 326 | syscallarg(int) uid; |
328 | syscallarg(void *) arg; | | 327 | syscallarg(void *) arg; |
329 | } */ | | 328 | } */ |
330 | struct mount *mp; | | | |
331 | int error; | | | |
332 | struct vnode *vp; | | 329 | struct vnode *vp; |
333 | int q1cmd = SCARG(uap, cmd); | | 330 | struct mount *mp; |
334 | char *bufpath; | | 331 | int q1cmd; |
| | | 332 | int idtype; |
| | | 333 | char *qfile; |
335 | struct dqblk dqblk; | | 334 | struct dqblk dqblk; |
336 | struct quotakey key; | | 335 | struct quotakey key; |
337 | struct quotaval blocks, files; | | 336 | struct quotaval blocks, files; |
338 | struct quotastat qstat; | | 337 | struct quotastat qstat; |
339 | struct vfs_quotactl_args args; | | 338 | struct vfs_quotactl_args args; |
340 | int idtype; | | 339 | int error; |
341 | | | 340 | |
342 | error = namei_simple_user(SCARG(uap, path), | | 341 | error = namei_simple_user(SCARG(uap, path), |
343 | NSM_FOLLOW_TRYEMULROOT, &vp); | | 342 | NSM_FOLLOW_TRYEMULROOT, &vp); |
344 | if (error != 0) | | 343 | if (error != 0) |
345 | return (error); | | 344 | return (error); |
346 | | | 345 | |
347 | mp = vp->v_mount; | | 346 | mp = vp->v_mount; |
| | | 347 | q1cmd = SCARG(uap, cmd); |
348 | idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK); | | 348 | idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK); |
349 | | | 349 | |
350 | switch ((q1cmd & ~SUBCMDMASK) >> SUBCMDSHIFT) { | | 350 | switch ((q1cmd & ~SUBCMDMASK) >> SUBCMDSHIFT) { |
351 | case Q_QUOTAON: | | 351 | case Q_QUOTAON: |
352 | bufpath = malloc(PATH_MAX * sizeof(char), M_TEMP, M_WAITOK); | | 352 | qfile = PNBUF_GET(); |
353 | error = copyinstr(SCARG(uap, arg), bufpath, PATH_MAX, NULL); | | 353 | error = copyinstr(SCARG(uap, arg), qfile, PATH_MAX, NULL); |
354 | if (error != 0) { | | 354 | if (error != 0) { |
355 | free(bufpath, M_TEMP); | | 355 | PNBUF_PUT(qfile); |
356 | break; | | 356 | break; |
357 | } | | 357 | } |
358 | | | 358 | |
359 | args.qc_op = QUOTACTL_QUOTAON; | | 359 | args.qc_op = QUOTACTL_QUOTAON; |
360 | args.u.quotaon.qc_quotafile = bufpath; | | 360 | args.u.quotaon.qc_quotafile = qfile; |
361 | args.u.quotaon.qc_idtype = idtype; | | 361 | args.u.quotaon.qc_idtype = idtype; |
362 | error = VFS_QUOTACTL(mp, &args); | | 362 | error = VFS_QUOTACTL(mp, &args); |
363 | | | 363 | |
364 | free(bufpath, M_TEMP); | | 364 | PNBUF_PUT(qfile); |
365 | break; | | 365 | break; |
366 | | | 366 | |
367 | case Q_QUOTAOFF: | | 367 | case Q_QUOTAOFF: |
368 | args.qc_op = QUOTACTL_QUOTAOFF; | | 368 | args.qc_op = QUOTACTL_QUOTAOFF; |
369 | args.u.quotaoff.qc_idtype = idtype; | | 369 | args.u.quotaoff.qc_idtype = idtype; |
370 | error = VFS_QUOTACTL(mp, &args); | | 370 | error = VFS_QUOTACTL(mp, &args); |
371 | break; | | 371 | break; |
372 | | | 372 | |
373 | case Q_GETQUOTA: | | 373 | case Q_GETQUOTA: |
374 | key.qk_idtype = idtype; | | 374 | key.qk_idtype = idtype; |
375 | key.qk_id = SCARG(uap, uid); | | 375 | key.qk_id = SCARG(uap, uid); |
376 | args.qc_op = QUOTACTL_GET; | | 376 | args.qc_op = QUOTACTL_GET; |
377 | args.u.get.qc_key = &key; | | 377 | args.u.get.qc_key = &key; |