ufs_quota.c (151897) | ufs_quota.c (153400) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1990, 1993, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Robert Elz at The University of Melbourne. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95 33 */ 34 35#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1990, 1993, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Robert Elz at The University of Melbourne. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95 33 */ 34 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: head/sys/ufs/ufs/ufs_quota.c 151897 2005-10-31 15:41:29Z rwatson $"); | 36__FBSDID("$FreeBSD: head/sys/ufs/ufs/ufs_quota.c 153400 2005-12-14 00:49:52Z des $"); |
37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/fcntl.h> 41#include <sys/kernel.h> 42#include <sys/lock.h> 43#include <sys/malloc.h> 44#include <sys/mount.h> --- 349 unchanged lines hidden (view full) --- 394/* 395 * Q_QUOTAON - set up a quota file for a particular filesystem. 396 */ 397int 398quotaon(td, mp, type, fname) 399 struct thread *td; 400 struct mount *mp; 401 int type; | 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/fcntl.h> 41#include <sys/kernel.h> 42#include <sys/lock.h> 43#include <sys/malloc.h> 44#include <sys/mount.h> --- 349 unchanged lines hidden (view full) --- 394/* 395 * Q_QUOTAON - set up a quota file for a particular filesystem. 396 */ 397int 398quotaon(td, mp, type, fname) 399 struct thread *td; 400 struct mount *mp; 401 int type; |
402 caddr_t fname; | 402 void *fname; |
403{ 404 struct ufsmount *ump = VFSTOUFS(mp); 405 struct vnode *vp, **vpp; 406 struct vnode *nvp; 407 struct dquot *dq; 408 int error, flags; 409 struct nameidata nd; 410 --- 139 unchanged lines hidden (view full) --- 550 * Q_GETQUOTA - return current values in a dqblk structure. 551 */ 552int 553getquota(td, mp, id, type, addr) 554 struct thread *td; 555 struct mount *mp; 556 u_long id; 557 int type; | 403{ 404 struct ufsmount *ump = VFSTOUFS(mp); 405 struct vnode *vp, **vpp; 406 struct vnode *nvp; 407 struct dquot *dq; 408 int error, flags; 409 struct nameidata nd; 410 --- 139 unchanged lines hidden (view full) --- 550 * Q_GETQUOTA - return current values in a dqblk structure. 551 */ 552int 553getquota(td, mp, id, type, addr) 554 struct thread *td; 555 struct mount *mp; 556 u_long id; 557 int type; |
558 caddr_t addr; | 558 void *addr; |
559{ 560 struct dquot *dq; 561 int error; 562 563 switch (type) { 564 case USRQUOTA: 565 if ((td->td_ucred->cr_uid != id) && !unprivileged_get_quota) { 566 error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL); --- 12 unchanged lines hidden (view full) --- 579 580 default: 581 return (EINVAL); 582 } 583 584 error = dqget(NULLVP, id, VFSTOUFS(mp), type, &dq); 585 if (error) 586 return (error); | 559{ 560 struct dquot *dq; 561 int error; 562 563 switch (type) { 564 case USRQUOTA: 565 if ((td->td_ucred->cr_uid != id) && !unprivileged_get_quota) { 566 error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL); --- 12 unchanged lines hidden (view full) --- 579 580 default: 581 return (EINVAL); 582 } 583 584 error = dqget(NULLVP, id, VFSTOUFS(mp), type, &dq); 585 if (error) 586 return (error); |
587 error = copyout((caddr_t)&dq->dq_dqb, addr, sizeof (struct dqblk)); | 587 error = copyout(&dq->dq_dqb, addr, sizeof (struct dqblk)); |
588 dqrele(NULLVP, dq); 589 return (error); 590} 591 592/* 593 * Q_SETQUOTA - assign an entire dqblk structure. 594 */ 595int 596setquota(td, mp, id, type, addr) 597 struct thread *td; 598 struct mount *mp; 599 u_long id; 600 int type; | 588 dqrele(NULLVP, dq); 589 return (error); 590} 591 592/* 593 * Q_SETQUOTA - assign an entire dqblk structure. 594 */ 595int 596setquota(td, mp, id, type, addr) 597 struct thread *td; 598 struct mount *mp; 599 u_long id; 600 int type; |
601 caddr_t addr; | 601 void *addr; |
602{ 603 struct dquot *dq; 604 struct dquot *ndq; 605 struct ufsmount *ump = VFSTOUFS(mp); 606 struct dqblk newlim; 607 int error; 608 609 error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL); 610 if (error) 611 return (error); 612 | 602{ 603 struct dquot *dq; 604 struct dquot *ndq; 605 struct ufsmount *ump = VFSTOUFS(mp); 606 struct dqblk newlim; 607 int error; 608 609 error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL); 610 if (error) 611 return (error); 612 |
613 error = copyin(addr, (caddr_t)&newlim, sizeof (struct dqblk)); | 613 error = copyin(addr, &newlim, sizeof (struct dqblk)); |
614 if (error) 615 return (error); 616 error = dqget(NULLVP, id, ump, type, &ndq); 617 if (error) 618 return (error); 619 dq = ndq; 620 while (dq->dq_flags & DQ_LOCK) { 621 dq->dq_flags |= DQ_WANT; --- 37 unchanged lines hidden (view full) --- 659 * Q_SETUSE - set current inode and block usage. 660 */ 661int 662setuse(td, mp, id, type, addr) 663 struct thread *td; 664 struct mount *mp; 665 u_long id; 666 int type; | 614 if (error) 615 return (error); 616 error = dqget(NULLVP, id, ump, type, &ndq); 617 if (error) 618 return (error); 619 dq = ndq; 620 while (dq->dq_flags & DQ_LOCK) { 621 dq->dq_flags |= DQ_WANT; --- 37 unchanged lines hidden (view full) --- 659 * Q_SETUSE - set current inode and block usage. 660 */ 661int 662setuse(td, mp, id, type, addr) 663 struct thread *td; 664 struct mount *mp; 665 u_long id; 666 int type; |
667 caddr_t addr; | 667 void *addr; |
668{ 669 struct dquot *dq; 670 struct ufsmount *ump = VFSTOUFS(mp); 671 struct dquot *ndq; 672 struct dqblk usage; 673 int error; 674 675 error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL); 676 if (error) 677 return (error); 678 | 668{ 669 struct dquot *dq; 670 struct ufsmount *ump = VFSTOUFS(mp); 671 struct dquot *ndq; 672 struct dqblk usage; 673 int error; 674 675 error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL); 676 if (error) 677 return (error); 678 |
679 error = copyin(addr, (caddr_t)&usage, sizeof (struct dqblk)); | 679 error = copyin(addr, &usage, sizeof (struct dqblk)); |
680 if (error) 681 return (error); 682 error = dqget(NULLVP, id, ump, type, &ndq); 683 if (error) 684 return (error); 685 dq = ndq; 686 while (dq->dq_flags & DQ_LOCK) { 687 dq->dq_flags |= DQ_WANT; --- 189 unchanged lines hidden (view full) --- 877 LIST_INSERT_HEAD(dqh, dq, dq_hash); 878 DQREF(dq); 879 dq->dq_flags = DQ_LOCK; 880 dq->dq_id = id; 881 dq->dq_ump = ump; 882 dq->dq_type = type; 883 auio.uio_iov = &aiov; 884 auio.uio_iovcnt = 1; | 680 if (error) 681 return (error); 682 error = dqget(NULLVP, id, ump, type, &ndq); 683 if (error) 684 return (error); 685 dq = ndq; 686 while (dq->dq_flags & DQ_LOCK) { 687 dq->dq_flags |= DQ_WANT; --- 189 unchanged lines hidden (view full) --- 877 LIST_INSERT_HEAD(dqh, dq, dq_hash); 878 DQREF(dq); 879 dq->dq_flags = DQ_LOCK; 880 dq->dq_id = id; 881 dq->dq_ump = ump; 882 dq->dq_type = type; 883 auio.uio_iov = &aiov; 884 auio.uio_iovcnt = 1; |
885 aiov.iov_base = (caddr_t)&dq->dq_dqb; | 885 aiov.iov_base = &dq->dq_dqb; |
886 aiov.iov_len = sizeof (struct dqblk); 887 auio.uio_resid = sizeof (struct dqblk); 888 auio.uio_offset = (off_t)(id * sizeof (struct dqblk)); 889 auio.uio_segflg = UIO_SYSSPACE; 890 auio.uio_rw = UIO_READ; 891 auio.uio_td = (struct thread *)0; 892 error = VOP_READ(dqvp, &auio, 0, ump->um_cred[type]); 893 if (auio.uio_resid == sizeof(struct dqblk) && error == 0) | 886 aiov.iov_len = sizeof (struct dqblk); 887 auio.uio_resid = sizeof (struct dqblk); 888 auio.uio_offset = (off_t)(id * sizeof (struct dqblk)); 889 auio.uio_segflg = UIO_SYSSPACE; 890 auio.uio_rw = UIO_READ; 891 auio.uio_td = (struct thread *)0; 892 error = VOP_READ(dqvp, &auio, 0, ump->um_cred[type]); 893 if (auio.uio_resid == sizeof(struct dqblk) && error == 0) |
894 bzero((caddr_t)&dq->dq_dqb, sizeof(struct dqblk)); | 894 bzero(&dq->dq_dqb, sizeof(struct dqblk)); |
895 if (vp != dqvp) 896 VOP_UNLOCK(dqvp, 0, td); 897 if (dq->dq_flags & DQ_WANT) 898 wakeup(dq); 899 dq->dq_flags = 0; 900 /* 901 * I/O error in reading quota file, release 902 * quota structure and reflect problem to caller. --- 86 unchanged lines hidden (view full) --- 989 if (vp != dqvp) 990 VOP_UNLOCK(dqvp, 0, td); 991 return (0); 992 } 993 } 994 dq->dq_flags |= DQ_LOCK; 995 auio.uio_iov = &aiov; 996 auio.uio_iovcnt = 1; | 895 if (vp != dqvp) 896 VOP_UNLOCK(dqvp, 0, td); 897 if (dq->dq_flags & DQ_WANT) 898 wakeup(dq); 899 dq->dq_flags = 0; 900 /* 901 * I/O error in reading quota file, release 902 * quota structure and reflect problem to caller. --- 86 unchanged lines hidden (view full) --- 989 if (vp != dqvp) 990 VOP_UNLOCK(dqvp, 0, td); 991 return (0); 992 } 993 } 994 dq->dq_flags |= DQ_LOCK; 995 auio.uio_iov = &aiov; 996 auio.uio_iovcnt = 1; |
997 aiov.iov_base = (caddr_t)&dq->dq_dqb; | 997 aiov.iov_base = &dq->dq_dqb; |
998 aiov.iov_len = sizeof (struct dqblk); 999 auio.uio_resid = sizeof (struct dqblk); 1000 auio.uio_offset = (off_t)(dq->dq_id * sizeof (struct dqblk)); 1001 auio.uio_segflg = UIO_SYSSPACE; 1002 auio.uio_rw = UIO_WRITE; 1003 auio.uio_td = (struct thread *)0; 1004 error = VOP_WRITE(dqvp, &auio, 0, dq->dq_ump->um_cred[dq->dq_type]); 1005 if (auio.uio_resid && error == 0) --- 36 unchanged lines hidden --- | 998 aiov.iov_len = sizeof (struct dqblk); 999 auio.uio_resid = sizeof (struct dqblk); 1000 auio.uio_offset = (off_t)(dq->dq_id * sizeof (struct dqblk)); 1001 auio.uio_segflg = UIO_SYSSPACE; 1002 auio.uio_rw = UIO_WRITE; 1003 auio.uio_td = (struct thread *)0; 1004 error = VOP_WRITE(dqvp, &auio, 0, dq->dq_ump->um_cred[dq->dq_type]); 1005 if (auio.uio_resid && error == 0) --- 36 unchanged lines hidden --- |