quot.c (162831) | quot.c (180187) |
---|---|
1/* 2 * Copyright (C) 1991, 1994 Wolfgang Solfrank. 3 * Copyright (C) 1991, 1994 TooLs GmbH. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> | 1/* 2 * Copyright (C) 1991, 1994 Wolfgang Solfrank. 3 * Copyright (C) 1991, 1994 TooLs GmbH. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/usr.sbin/quot/quot.c 162831 2006-09-30 07:34:20Z maxim $"); | 33__FBSDID("$FreeBSD: head/usr.sbin/quot/quot.c 180187 2008-07-02 15:51:59Z des $"); |
34 35#include <sys/param.h> 36#include <sys/stdint.h> 37#include <sys/mount.h> 38#include <sys/disklabel.h> 39#include <sys/time.h> 40#include <ufs/ufs/dinode.h> 41#include <ufs/ffs/fs.h> --- 59 unchanged lines hidden (view full) --- 101 struct ufs1_dinode dp1; 102 struct ufs2_dinode dp2; 103}; 104#define DIP(fs, dp, field) \ 105 (((fs)->fs_magic == FS_UFS1_MAGIC) ? \ 106 (dp)->dp1.field : (dp)->dp2.field) 107 108static union dinode * | 34 35#include <sys/param.h> 36#include <sys/stdint.h> 37#include <sys/mount.h> 38#include <sys/disklabel.h> 39#include <sys/time.h> 40#include <ufs/ufs/dinode.h> 41#include <ufs/ffs/fs.h> --- 59 unchanged lines hidden (view full) --- 101 struct ufs1_dinode dp1; 102 struct ufs2_dinode dp2; 103}; 104#define DIP(fs, dp, field) \ 105 (((fs)->fs_magic == FS_UFS1_MAGIC) ? \ 106 (dp)->dp1.field : (dp)->dp2.field) 107 108static union dinode * |
109get_inode(fd,super,ino) 110 int fd; 111 struct fs *super; 112 ino_t ino; | 109get_inode(int fd, struct fs *super, ino_t ino) |
113{ 114 static caddr_t ipbuf; 115 static struct cg *cgp; 116 static ino_t last; 117 static int cg; 118 struct ufs2_dinode *di2; | 110{ 111 static caddr_t ipbuf; 112 static struct cg *cgp; 113 static ino_t last; 114 static int cg; 115 struct ufs2_dinode *di2; |
119 | 116 |
120 if (fd < 0) { /* flush cache */ 121 if (ipbuf) { 122 free(ipbuf); 123 ipbuf = 0; 124 if (super != NULL && super->fs_magic == FS_UFS2_MAGIC) { 125 free(cgp); 126 cgp = 0; 127 } 128 } 129 return 0; 130 } | 117 if (fd < 0) { /* flush cache */ 118 if (ipbuf) { 119 free(ipbuf); 120 ipbuf = 0; 121 if (super != NULL && super->fs_magic == FS_UFS2_MAGIC) { 122 free(cgp); 123 cgp = 0; 124 } 125 } 126 return 0; 127 } |
131 | 128 |
132 if (!ipbuf || ino < last || ino >= last + INOCNT(super)) { 133 if (super->fs_magic == FS_UFS2_MAGIC && 134 (!cgp || cg != ino_to_cg(super, ino))) { 135 cg = ino_to_cg(super, ino); 136 if (!cgp && !(cgp = malloc(super->fs_cgsize))) 137 errx(1, "allocate cg"); 138 if (lseek(fd, (off_t)cgtod(super, cg) << super->fs_fshift, 0) < 0) 139 err(1, "lseek cg"); --- 5 unchanged lines hidden (view full) --- 145 if (!ipbuf 146 && !(ipbuf = malloc(INOSZ(super)))) 147 errx(1, "allocate inodes"); 148 last = (ino / INOCNT(super)) * INOCNT(super); 149 if (lseek(fd, (off_t)ino_to_fsba(super, last) << super->fs_fshift, 0) < (off_t)0 150 || read(fd, ipbuf, INOSZ(super)) != (ssize_t)INOSZ(super)) 151 err(1, "read inodes"); 152 } | 129 if (!ipbuf || ino < last || ino >= last + INOCNT(super)) { 130 if (super->fs_magic == FS_UFS2_MAGIC && 131 (!cgp || cg != ino_to_cg(super, ino))) { 132 cg = ino_to_cg(super, ino); 133 if (!cgp && !(cgp = malloc(super->fs_cgsize))) 134 errx(1, "allocate cg"); 135 if (lseek(fd, (off_t)cgtod(super, cg) << super->fs_fshift, 0) < 0) 136 err(1, "lseek cg"); --- 5 unchanged lines hidden (view full) --- 142 if (!ipbuf 143 && !(ipbuf = malloc(INOSZ(super)))) 144 errx(1, "allocate inodes"); 145 last = (ino / INOCNT(super)) * INOCNT(super); 146 if (lseek(fd, (off_t)ino_to_fsba(super, last) << super->fs_fshift, 0) < (off_t)0 147 || read(fd, ipbuf, INOSZ(super)) != (ssize_t)INOSZ(super)) 148 err(1, "read inodes"); 149 } |
153 | 150 |
154 if (super->fs_magic == FS_UFS1_MAGIC) 155 return ((union dinode *) 156 &((struct ufs1_dinode *)ipbuf)[ino % INOCNT(super)]); 157 di2 = &((struct ufs2_dinode *)ipbuf)[ino % INOCNT(super)]; 158 /* If the inode is unused, it might be unallocated too, so zero it. */ 159 if (isclr(cg_inosused(cgp), ino % super->fs_ipg)) 160 bzero(di2, sizeof (*di2)); 161 return ((union dinode *)di2); 162} 163 164#ifdef COMPAT 165#define actualblocks(fs, dp) (DIP(fs, dp, di_blocks) / 2) 166#else 167#define actualblocks(fs, dp) DIP(fs, dp, di_blocks) 168#endif 169 | 151 if (super->fs_magic == FS_UFS1_MAGIC) 152 return ((union dinode *) 153 &((struct ufs1_dinode *)ipbuf)[ino % INOCNT(super)]); 154 di2 = &((struct ufs2_dinode *)ipbuf)[ino % INOCNT(super)]; 155 /* If the inode is unused, it might be unallocated too, so zero it. */ 156 if (isclr(cg_inosused(cgp), ino % super->fs_ipg)) 157 bzero(di2, sizeof (*di2)); 158 return ((union dinode *)di2); 159} 160 161#ifdef COMPAT 162#define actualblocks(fs, dp) (DIP(fs, dp, di_blocks) / 2) 163#else 164#define actualblocks(fs, dp) DIP(fs, dp, di_blocks) 165#endif 166 |
170static int virtualblocks(super, dp) 171 struct fs *super; 172 union dinode *dp; | 167static int virtualblocks(struct fs *super, union dinode *dp) |
173{ | 168{ |
174 register off_t nblk, sz; 175 | 169 off_t nblk, sz; 170 |
176 sz = DIP(super, dp, di_size); 177#ifdef COMPAT 178 if (lblkno(super,sz) >= NDADDR) { 179 nblk = blkroundup(super,sz); 180 if (sz == nblk) 181 nblk += super->fs_bsize; 182 } | 171 sz = DIP(super, dp, di_size); 172#ifdef COMPAT 173 if (lblkno(super,sz) >= NDADDR) { 174 nblk = blkroundup(super,sz); 175 if (sz == nblk) 176 nblk += super->fs_bsize; 177 } |
183 | 178 |
184 return sz / 1024; | 179 return sz / 1024; |
185 | 180 |
186#else /* COMPAT */ | 181#else /* COMPAT */ |
187 | 182 |
188 if (lblkno(super,sz) >= NDADDR) { 189 nblk = blkroundup(super,sz); 190 sz = lblkno(super,nblk); 191 sz = (sz - NDADDR + NINDIR(super) - 1) / NINDIR(super); 192 while (sz > 0) { 193 nblk += sz * super->fs_bsize; 194 /* sz - 1 rounded up */ 195 sz = (sz - 1 + NINDIR(super) - 1) / NINDIR(super); 196 } 197 } else 198 nblk = fragroundup(super,sz); | 183 if (lblkno(super,sz) >= NDADDR) { 184 nblk = blkroundup(super,sz); 185 sz = lblkno(super,nblk); 186 sz = (sz - NDADDR + NINDIR(super) - 1) / NINDIR(super); 187 while (sz > 0) { 188 nblk += sz * super->fs_bsize; 189 /* sz - 1 rounded up */ 190 sz = (sz - 1 + NINDIR(super) - 1) / NINDIR(super); 191 } 192 } else 193 nblk = fragroundup(super,sz); |
199 | 194 |
200 return nblk / 512; 201#endif /* COMPAT */ 202} 203 204static int | 195 return nblk / 512; 196#endif /* COMPAT */ 197} 198 199static int |
205isfree(super, dp) 206 struct fs *super; 207 union dinode *dp; | 200isfree(struct fs *super, union dinode *dp) |
208{ 209#ifdef COMPAT 210 return (DIP(super, dp, di_mode) & IFMT) == 0; 211#else /* COMPAT */ | 201{ 202#ifdef COMPAT 203 return (DIP(super, dp, di_mode) & IFMT) == 0; 204#else /* COMPAT */ |
212 | 205 |
213 switch (DIP(super, dp, di_mode) & IFMT) { 214 case IFIFO: 215 case IFLNK: /* should check FASTSYMLINK? */ 216 case IFDIR: 217 case IFREG: 218 return 0; 219 case IFCHR: 220 case IFBLK: --- 14 unchanged lines hidden (view full) --- 235 long count; 236 daddr_t spc30; 237 daddr_t spc60; 238 daddr_t spc90; 239} *users; 240static int nusers; 241 242static void | 206 switch (DIP(super, dp, di_mode) & IFMT) { 207 case IFIFO: 208 case IFLNK: /* should check FASTSYMLINK? */ 209 case IFDIR: 210 case IFREG: 211 return 0; 212 case IFCHR: 213 case IFBLK: --- 14 unchanged lines hidden (view full) --- 228 long count; 229 daddr_t spc30; 230 daddr_t spc60; 231 daddr_t spc90; 232} *users; 233static int nusers; 234 235static void |
243inituser() | 236inituser(void) |
244{ | 237{ |
245 register int i; 246 register struct user *usr; 247 | 238 int i; 239 struct user *usr; 240 |
248 if (!nusers) { 249 nusers = 8; 250 if (!(users = 251 (struct user *)calloc(nusers,sizeof(struct user)))) 252 errx(1, "allocate users"); 253 } else { 254 for (usr = users, i = nusers; --i >= 0; usr++) { 255 usr->space = usr->spc30 = usr->spc60 = usr->spc90 = 0; 256 usr->count = 0; 257 } 258 } 259} 260 261static void | 241 if (!nusers) { 242 nusers = 8; 243 if (!(users = 244 (struct user *)calloc(nusers,sizeof(struct user)))) 245 errx(1, "allocate users"); 246 } else { 247 for (usr = users, i = nusers; --i >= 0; usr++) { 248 usr->space = usr->spc30 = usr->spc60 = usr->spc90 = 0; 249 usr->count = 0; 250 } 251 } 252} 253 254static void |
262usrrehash() | 255usrrehash(void) |
263{ | 256{ |
264 register int i; 265 register struct user *usr, *usrn; | 257 int i; 258 struct user *usr, *usrn; |
266 struct user *svusr; | 259 struct user *svusr; |
267 | 260 |
268 svusr = users; 269 nusers <<= 1; 270 if (!(users = (struct user *)calloc(nusers,sizeof(struct user)))) 271 errx(1, "allocate users"); 272 for (usr = svusr, i = nusers >> 1; --i >= 0; usr++) { 273 for (usrn = users + (usr->uid&(nusers - 1)); usrn->name; 274 usrn--) { 275 if (usrn <= users) 276 usrn = users + nusers; 277 } 278 *usrn = *usr; 279 } 280} 281 282static struct user * | 261 svusr = users; 262 nusers <<= 1; 263 if (!(users = (struct user *)calloc(nusers,sizeof(struct user)))) 264 errx(1, "allocate users"); 265 for (usr = svusr, i = nusers >> 1; --i >= 0; usr++) { 266 for (usrn = users + (usr->uid&(nusers - 1)); usrn->name; 267 usrn--) { 268 if (usrn <= users) 269 usrn = users + nusers; 270 } 271 *usrn = *usr; 272 } 273} 274 275static struct user * |
283user(uid) 284 uid_t uid; | 276user(uid_t uid) |
285{ | 277{ |
286 register struct user *usr; 287 register int i; | 278 struct user *usr; 279 int i; |
288 struct passwd *pwd; | 280 struct passwd *pwd; |
289 | 281 |
290 while (1) { 291 for (usr = users + (uid&(nusers - 1)), i = nusers; --i >= 0; 292 usr--) { 293 if (!usr->name) { 294 usr->uid = uid; | 282 while (1) { 283 for (usr = users + (uid&(nusers - 1)), i = nusers; --i >= 0; 284 usr--) { 285 if (!usr->name) { 286 usr->uid = uid; |
295 | 287 |
296 if (!(pwd = getpwuid(uid))) { 297 if ((usr->name = (char *)malloc(7))) 298 sprintf(usr->name,"#%d",uid); 299 } else { 300 if ((usr->name = (char *) 301 malloc(strlen(pwd->pw_name) + 1))) 302 strcpy(usr->name,pwd->pw_name); 303 } 304 if (!usr->name) 305 errx(1, "allocate users"); | 288 if (!(pwd = getpwuid(uid))) { 289 if ((usr->name = (char *)malloc(7))) 290 sprintf(usr->name,"#%d",uid); 291 } else { 292 if ((usr->name = (char *) 293 malloc(strlen(pwd->pw_name) + 1))) 294 strcpy(usr->name,pwd->pw_name); 295 } 296 if (!usr->name) 297 errx(1, "allocate users"); |
306 | 298 |
307 return usr; | 299 return usr; |
308 | 300 |
309 } else if (usr->uid == uid) 310 return usr; 311 312 if (usr <= users) 313 usr = users + nusers; 314 } 315 usrrehash(); 316 } 317} 318 319static int | 301 } else if (usr->uid == uid) 302 return usr; 303 304 if (usr <= users) 305 usr = users + nusers; 306 } 307 usrrehash(); 308 } 309} 310 311static int |
320cmpusers(v1,v2) 321 const void *v1, *v2; | 312cmpusers(const void *v1, const void *v2) |
322{ 323 const struct user *u1, *u2; 324 u1 = (const struct user *)v1; 325 u2 = (const struct user *)v2; 326 327 return u2->space - u1->space; 328} 329 330#define sortusers(users) (qsort((users),nusers,sizeof(struct user), \ 331 cmpusers)) 332 333static void | 313{ 314 const struct user *u1, *u2; 315 u1 = (const struct user *)v1; 316 u2 = (const struct user *)v2; 317 318 return u2->space - u1->space; 319} 320 321#define sortusers(users) (qsort((users),nusers,sizeof(struct user), \ 322 cmpusers)) 323 324static void |
334uses(uid,blks,act) 335 uid_t uid; 336 daddr_t blks; 337 time_t act; | 325uses(uid_t uid, daddr_t blks, time_t act) |
338{ 339 static time_t today; | 326{ 327 static time_t today; |
340 register struct user *usr; 341 | 328 struct user *usr; 329 |
342 if (!today) 343 time(&today); | 330 if (!today) 331 time(&today); |
344 | 332 |
345 usr = user(uid); 346 usr->count++; 347 usr->space += blks; | 333 usr = user(uid); 334 usr->count++; 335 usr->space += blks; |
348 | 336 |
349 if (today - act > 90L * 24L * 60L * 60L) 350 usr->spc90 += blks; 351 if (today - act > 60L * 24L * 60L * 60L) 352 usr->spc60 += blks; 353 if (today - act > 30L * 24L * 60L * 60L) 354 usr->spc30 += blks; 355} 356 --- 5 unchanged lines hidden (view full) --- 362struct fsizes { 363 struct fsizes *fsz_next; 364 daddr_t fsz_first, fsz_last; 365 ino_t fsz_count[FSZCNT]; 366 daddr_t fsz_sz[FSZCNT]; 367} *fsizes; 368 369static void | 337 if (today - act > 90L * 24L * 60L * 60L) 338 usr->spc90 += blks; 339 if (today - act > 60L * 24L * 60L * 60L) 340 usr->spc60 += blks; 341 if (today - act > 30L * 24L * 60L * 60L) 342 usr->spc30 += blks; 343} 344 --- 5 unchanged lines hidden (view full) --- 350struct fsizes { 351 struct fsizes *fsz_next; 352 daddr_t fsz_first, fsz_last; 353 ino_t fsz_count[FSZCNT]; 354 daddr_t fsz_sz[FSZCNT]; 355} *fsizes; 356 357static void |
370initfsizes() | 358initfsizes(void) |
371{ | 359{ |
372 register struct fsizes *fp; 373 register int i; 374 | 360 struct fsizes *fp; 361 int i; 362 |
375 for (fp = fsizes; fp; fp = fp->fsz_next) { 376 for (i = FSZCNT; --i >= 0;) { 377 fp->fsz_count[i] = 0; 378 fp->fsz_sz[i] = 0; 379 } 380 } 381} 382 383static void | 363 for (fp = fsizes; fp; fp = fp->fsz_next) { 364 for (i = FSZCNT; --i >= 0;) { 365 fp->fsz_count[i] = 0; 366 fp->fsz_sz[i] = 0; 367 } 368 } 369} 370 371static void |
384dofsizes(fd, super, name) 385 int fd; 386 struct fs *super; 387 char *name; | 372dofsizes(int fd, struct fs *super, char *name) |
388{ 389 ino_t inode, maxino; 390 union dinode *dp; 391 daddr_t sz, ksz; 392 struct fsizes *fp, **fsp; | 373{ 374 ino_t inode, maxino; 375 union dinode *dp; 376 daddr_t sz, ksz; 377 struct fsizes *fp, **fsp; |
393 register int i; 394 | 378 int i; 379 |
395 maxino = super->fs_ncg * super->fs_ipg - 1; 396#ifdef COMPAT 397 if (!(fsizes = (struct fsizes *)malloc(sizeof(struct fsizes)))) 398 errx(1, "allocate fsize structure"); 399#endif /* COMPAT */ 400 for (inode = 0; inode < maxino; inode++) { 401 errno = 0; 402 if ((dp = get_inode(fd,super,inode)) --- 48 unchanged lines hidden (view full) --- 451 (intmax_t)(fp->fsz_first + i), 452 (intmax_t)fp->fsz_count[i], 453 SIZE(sz += fp->fsz_sz[i])); 454 } 455 } 456} 457 458static void | 380 maxino = super->fs_ncg * super->fs_ipg - 1; 381#ifdef COMPAT 382 if (!(fsizes = (struct fsizes *)malloc(sizeof(struct fsizes)))) 383 errx(1, "allocate fsize structure"); 384#endif /* COMPAT */ 385 for (inode = 0; inode < maxino; inode++) { 386 errno = 0; 387 if ((dp = get_inode(fd,super,inode)) --- 48 unchanged lines hidden (view full) --- 436 (intmax_t)(fp->fsz_first + i), 437 (intmax_t)fp->fsz_count[i], 438 SIZE(sz += fp->fsz_sz[i])); 439 } 440 } 441} 442 443static void |
459douser(fd, super, name) 460 int fd; 461 struct fs *super; 462 char *name; | 444douser(int fd, struct fs *super, char *name) |
463{ 464 ino_t inode, maxino; 465 struct user *usr, *usrs; 466 union dinode *dp; | 445{ 446 ino_t inode, maxino; 447 struct user *usr, *usrs; 448 union dinode *dp; |
467 register int n; 468 | 449 int n; 450 |
469 maxino = super->fs_ncg * super->fs_ipg - 1; 470 for (inode = 0; inode < maxino; inode++) { 471 errno = 0; 472 if ((dp = get_inode(fd,super,inode)) 473 && !isfree(super, dp)) 474 uses(DIP(super, dp, di_uid), 475 estimate ? virtualblocks(super, dp) : 476 actualblocks(super, dp), --- 17 unchanged lines hidden (view full) --- 494 SIZE(usr->spc60), 495 SIZE(usr->spc90)); 496 printf("\n"); 497 } 498 free(usrs); 499} 500 501static void | 451 maxino = super->fs_ncg * super->fs_ipg - 1; 452 for (inode = 0; inode < maxino; inode++) { 453 errno = 0; 454 if ((dp = get_inode(fd,super,inode)) 455 && !isfree(super, dp)) 456 uses(DIP(super, dp, di_uid), 457 estimate ? virtualblocks(super, dp) : 458 actualblocks(super, dp), --- 17 unchanged lines hidden (view full) --- 476 SIZE(usr->spc60), 477 SIZE(usr->spc90)); 478 printf("\n"); 479 } 480 free(usrs); 481} 482 483static void |
502donames(fd, super, name) 503 int fd; 504 struct fs *super; 505 char *name; | 484donames(int fd, struct fs *super, char *name) |
506{ 507 int c; 508 ino_t inode; 509 ino_t maxino; 510 union dinode *dp; | 485{ 486 int c; 487 ino_t inode; 488 ino_t maxino; 489 union dinode *dp; |
511 | 490 |
512 maxino = super->fs_ncg * super->fs_ipg - 1; 513 /* first skip the name of the filesystem */ 514 while ((c = getchar()) != EOF && (c < '0' || c > '9')) 515 while ((c = getchar()) != EOF && c != '\n'); 516 ungetc(c,stdin); 517 while (scanf("%u",&inode) == 1) { 518 if (inode > maxino) { 519 warnx("illegal inode %d",inode); --- 19 unchanged lines hidden (view full) --- 539 while ((c = getchar()) != EOF && c != '\n'); 540 } 541 if (c == EOF) 542 break; 543 } 544} 545 546static void | 491 maxino = super->fs_ncg * super->fs_ipg - 1; 492 /* first skip the name of the filesystem */ 493 while ((c = getchar()) != EOF && (c < '0' || c > '9')) 494 while ((c = getchar()) != EOF && c != '\n'); 495 ungetc(c,stdin); 496 while (scanf("%u",&inode) == 1) { 497 if (inode > maxino) { 498 warnx("illegal inode %d",inode); --- 19 unchanged lines hidden (view full) --- 518 while ((c = getchar()) != EOF && c != '\n'); 519 } 520 if (c == EOF) 521 break; 522 } 523} 524 525static void |
547usage() | 526usage(void) |
548{ 549#ifdef COMPAT 550 fprintf(stderr,"usage: quot [-nfcvha] [filesystem ...]\n"); 551#else /* COMPAT */ 552 fprintf(stderr,"usage: quot [-acfhknv] [filesystem ...]\n"); 553#endif /* COMPAT */ 554 exit(1); 555} 556 557/* 558 * Possible superblock locations ordered from most to least likely. 559 */ 560static int sblock_try[] = SBLOCKSEARCH; 561static char superblock[SBLOCKSIZE]; 562 563void | 527{ 528#ifdef COMPAT 529 fprintf(stderr,"usage: quot [-nfcvha] [filesystem ...]\n"); 530#else /* COMPAT */ 531 fprintf(stderr,"usage: quot [-acfhknv] [filesystem ...]\n"); 532#endif /* COMPAT */ 533 exit(1); 534} 535 536/* 537 * Possible superblock locations ordered from most to least likely. 538 */ 539static int sblock_try[] = SBLOCKSEARCH; 540static char superblock[SBLOCKSIZE]; 541 542void |
564quot(name,mp) 565 char *name, *mp; | 543quot(char *name, char *mp) |
566{ 567 int i, fd; 568 struct fs *fs; | 544{ 545 int i, fd; 546 struct fs *fs; |
569 | 547 |
570 get_inode(-1, NULL, 0); /* flush cache */ 571 inituser(); 572 initfsizes(); 573 if ((fd = open(name,0)) < 0) { 574 warn("%s", name); 575 close(fd); 576 return; 577 } --- 23 unchanged lines hidden (view full) --- 601 if (mp) 602 printf(" (%s)",mp); 603 putchar('\n'); 604 (*func)(fd, fs, name); 605 close(fd); 606} 607 608int | 548 get_inode(-1, NULL, 0); /* flush cache */ 549 inituser(); 550 initfsizes(); 551 if ((fd = open(name,0)) < 0) { 552 warn("%s", name); 553 close(fd); 554 return; 555 } --- 23 unchanged lines hidden (view full) --- 579 if (mp) 580 printf(" (%s)",mp); 581 putchar('\n'); 582 (*func)(fd, fs, name); 583 close(fd); 584} 585 586int |
609main(argc,argv) 610 int argc; 611 char **argv; | 587main(int argc, char *argv[]) |
612{ 613 char all = 0; 614 struct statfs *mp; 615 struct fstab *fs; 616 char dev[MNAMELEN + 1]; 617 char *nm; 618 int cnt; | 588{ 589 char all = 0; 590 struct statfs *mp; 591 struct fstab *fs; 592 char dev[MNAMELEN + 1]; 593 char *nm; 594 int cnt; |
619 | 595 |
620 func = douser; 621#ifndef COMPAT 622 header = getbsize(&headerlen,&blocksize); 623#endif 624 while (--argc > 0 && **++argv == '-') { 625 while (*++*argv) { 626 switch (**argv) { 627 case 'n': --- 49 unchanged lines hidden --- | 596 func = douser; 597#ifndef COMPAT 598 header = getbsize(&headerlen,&blocksize); 599#endif 600 while (--argc > 0 && **++argv == '-') { 601 while (*++*argv) { 602 switch (**argv) { 603 case 'n': --- 49 unchanged lines hidden --- |