Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
e9fed4d6 | 2 | * Copyright (c) 1991 The Regents of the University of California. |
7188ac27 | 3 | * All rights reserved. |
da7c5cc6 | 4 | * |
b702c21d | 5 | * %sccs.include.redist.c% |
7188ac27 | 6 | * |
60bd7e2e | 7 | * @(#)ufs_vfsops.c 7.58 (Berkeley) %G% |
da7c5cc6 | 8 | */ |
71e4e98b | 9 | |
e9fed4d6 KB |
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> | |
609e7cfa MK |
16 | #include "ioctl.h" |
17 | #include "disklabel.h" | |
18 | #include "stat.h" | |
71e4e98b | 19 | |
e9fed4d6 KB |
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> | |
7188ac27 | 24 | |
d85a9d1b | 25 | /* |
e9fed4d6 | 26 | * Flag to permit forcible unmounting. |
d85a9d1b KM |
27 | */ |
28 | int doforce = 1; | |
29 | ||
5bf9d21f KM |
30 | /* |
31 | * Make a filesystem operational. | |
32 | * Nothing to do at the moment. | |
33 | */ | |
31593ba7 | 34 | /* ARGSUSED */ |
e9fed4d6 | 35 | int |
0eb6f54a | 36 | ufs_start(mp, flags, p) |
5bf9d21f KM |
37 | struct mount *mp; |
38 | int flags; | |
0eb6f54a | 39 | struct proc *p; |
5bf9d21f KM |
40 | { |
41 | ||
42 | return (0); | |
43 | } | |
71e4e98b | 44 | |
7188ac27 | 45 | /* |
ec67a3ce MK |
46 | error = closei(dev, IFBLK, fs->fs_ronly? FREAD : FREAD|FWRITE); |
47 | irele(ip); | |
48 | return (error); | |
71e4e98b SL |
49 | } |
50 | ||
8dc876c1 KM |
51 | /* |
52 | * Do operations associated with quotas | |
53 | */ | |
e9fed4d6 | 54 | int |
0eb6f54a | 55 | ufs_quotactl(mp, cmds, uid, arg, p) |
8dc876c1 KM |
56 | struct mount *mp; |
57 | int cmds; | |
e9fed4d6 | 58 | u_int uid; |
8dc876c1 | 59 | caddr_t arg; |
0eb6f54a | 60 | struct proc *p; |
8dc876c1 | 61 | { |
8dc876c1 KM |
62 | int cmd, type, error; |
63 | ||
64 | #ifndef QUOTA | |
65 | return (EOPNOTSUPP); | |
66 | #else | |
67 | if (uid == -1) | |
c6f5111d | 68 | uid = p->p_cred->p_ruid; |
8dc876c1 KM |
69 | cmd = cmds >> SUBCMDSHIFT; |
70 | ||
71 | switch (cmd) { | |
72 | case Q_GETQUOTA: | |
73 | case Q_SYNC: | |
c6f5111d | 74 | if (uid == p->p_cred->p_ruid) |
8dc876c1 KM |
75 | break; |
76 | /* fall through */ | |
77 | default: | |
c6f5111d | 78 | if (error = suser(p->p_ucred, &p->p_acflag)) |
8dc876c1 KM |
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: | |
c6f5111d | 89 | return (quotaon(p, mp, type, arg)); |
8dc876c1 KM |
90 | |
91 | case Q_QUOTAOFF: | |
92 | if (vfs_busy(mp)) | |
93 | return (0); | |
70a360ba | 94 | error = quotaoff(p, mp, type); |
8dc876c1 KM |
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 | ||
e9fed4d6 | 121 | int syncprt = 0; |
71e4e98b SL |
122 | |
123 | /* | |
7188ac27 KM |
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 | */ | |
e9fed4d6 KB |
128 | void |
129 | ufs_bufstats() | |
7188ac27 KM |
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 | } |