dynamically allocate private part
[unix-history] / usr / src / sys / ufs / ffs / ufs_vfsops.c
... / ...
CommitLineData
1/*
2 * Copyright (c) 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 *
7 * @(#)ufs_vfsops.c 7.58 (Berkeley) %G%
8 */
9
10#include <sys/param.h>
11#include <sys/mount.h>
12#include <sys/proc.h>
13#include <sys/buf.h>
14#include <sys/vnode.h>
15#include <sys/specdev.h>
16#include "ioctl.h"
17#include "disklabel.h"
18#include "stat.h"
19
20#include <ufs/ufs/quota.h>
21#include <ufs/ufs/inode.h>
22#include <ufs/ufs/ufsmount.h>
23#include <ufs/ufs/ufs_extern.h>
24
25/*
26 * Flag to permit forcible unmounting.
27 */
28int doforce = 1;
29
30/*
31 * Make a filesystem operational.
32 * Nothing to do at the moment.
33 */
34/* ARGSUSED */
35int
36ufs_start(mp, flags, p)
37 struct mount *mp;
38 int flags;
39 struct proc *p;
40{
41
42 return (0);
43}
44
45/*
46 error = closei(dev, IFBLK, fs->fs_ronly? FREAD : FREAD|FWRITE);
47 irele(ip);
48 return (error);
49}
50
51/*
52 * Do operations associated with quotas
53 */
54int
55ufs_quotactl(mp, cmds, uid, arg, p)
56 struct mount *mp;
57 int cmds;
58 u_int uid;
59 caddr_t arg;
60 struct proc *p;
61{
62 int cmd, type, error;
63
64#ifndef QUOTA
65 return (EOPNOTSUPP);
66#else
67 if (uid == -1)
68 uid = p->p_cred->p_ruid;
69 cmd = cmds >> SUBCMDSHIFT;
70
71 switch (cmd) {
72 case Q_GETQUOTA:
73 case Q_SYNC:
74 if (uid == p->p_cred->p_ruid)
75 break;
76 /* fall through */
77 default:
78 if (error = suser(p->p_ucred, &p->p_acflag))
79 return (error);
80 }
81
82 type = cmd & SUBCMDMASK;
83 if ((u_int)type >= MAXQUOTAS)
84 return (EINVAL);
85
86 switch (cmd) {
87
88 case Q_QUOTAON:
89 return (quotaon(p, mp, type, arg));
90
91 case Q_QUOTAOFF:
92 if (vfs_busy(mp))
93 return (0);
94 error = quotaoff(p, mp, type);
95 vfs_unbusy(mp);
96 return (error);
97
98 case Q_SETQUOTA:
99 return (setquota(mp, uid, type, arg));
100
101 case Q_SETUSE:
102 return (setuse(mp, uid, type, arg));
103
104 case Q_GETQUOTA:
105 return (getquota(mp, uid, type, arg));
106
107 case Q_SYNC:
108 if (vfs_busy(mp))
109 return (0);
110 error = qsync(mp);
111 vfs_unbusy(mp);
112 return (error);
113
114 default:
115 return (EINVAL);
116 }
117 /* NOTREACHED */
118#endif
119}
120
121int syncprt = 0;
122
123/*
124 * Print out statistics on the current allocation of the buffer pool.
125 * Can be enabled to print out on every ``sync'' by setting "syncprt"
126 * above.
127 */
128void
129ufs_bufstats()
130{
131 int s, i, j, count;
132 register struct buf *bp, *dp;
133 int counts[MAXBSIZE/CLBYTES+1];
134 static char *bname[BQUEUES] = { "LOCKED", "LRU", "AGE", "EMPTY" };
135
136 for (bp = bfreelist, i = 0; bp < &bfreelist[BQUEUES]; bp++, i++) {
137 count = 0;
138 for (j = 0; j <= MAXBSIZE/CLBYTES; j++)
139 counts[j] = 0;
140 s = splbio();
141 for (dp = bp->av_forw; dp != bp; dp = dp->av_forw) {
142 counts[dp->b_bufsize/CLBYTES]++;
143 count++;
144 }
145 splx(s);
146 printf("%s: total-%d", bname[i], count);
147 for (j = 0; j <= MAXBSIZE/CLBYTES; j++)
148 if (counts[j] != 0)
149 printf(", %d-%d", j * CLBYTES, counts[j]);
150 printf("\n");
151 }
152}