quota.c (92921) | quota.c (95624) |
---|---|
1/* 2 * Copyright (c) 1980, 1990, 1993 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 --- 24 unchanged lines hidden (view full) --- 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38static const char copyright[] = 39"@(#) Copyright (c) 1980, 1990, 1993\n\ 40 The Regents of the University of California. All rights reserved.\n"; | 1/* 2 * Copyright (c) 1980, 1990, 1993 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 --- 24 unchanged lines hidden (view full) --- 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38static const char copyright[] = 39"@(#) Copyright (c) 1980, 1990, 1993\n\ 40 The Regents of the University of California. All rights reserved.\n"; |
41#endif /* not lint */ | 41#endif |
42 43#ifndef lint | 42 43#ifndef lint |
44#if 0 45static char sccsid[] = "from: @(#)quota.c 8.1 (Berkeley) 6/6/93"; 46#endif 47static const char rcsid[] = 48 "$FreeBSD: head/usr.bin/quota/quota.c 92921 2002-03-22 01:33:25Z imp $"; | 44static const char sccsid[] = "from: @(#)quota.c 8.1 (Berkeley) 6/6/93"; |
49#endif /* not lint */ 50 51/* 52 * Disk quota reporting program. 53 */ | 45#endif /* not lint */ 46 47/* 48 * Disk quota reporting program. 49 */ |
50#include <sys/cdefs.h> 51__FBSDID("$FreeBSD: head/usr.bin/quota/quota.c 95624 2002-04-28 11:44:30Z markm $"); 52 |
|
54#include <sys/param.h> 55#include <sys/types.h> 56#include <sys/file.h> 57#include <sys/stat.h> 58#include <sys/mount.h> 59#include <sys/socket.h> | 53#include <sys/param.h> 54#include <sys/types.h> 55#include <sys/file.h> 56#include <sys/stat.h> 57#include <sys/mount.h> 58#include <sys/socket.h> |
59 60#include <rpc/rpc.h> 61#include <rpc/pmap_prot.h> 62#include <rpcsvc/rquota.h> 63 |
|
60#include <ufs/ufs/quota.h> | 64#include <ufs/ufs/quota.h> |
65 |
|
61#include <ctype.h> 62#include <err.h> 63#include <fstab.h> 64#include <grp.h> | 66#include <ctype.h> 67#include <err.h> 68#include <fstab.h> 69#include <grp.h> |
70#include <netdb.h> |
|
65#include <pwd.h> 66#include <stdio.h> 67#include <stdlib.h> 68#include <string.h> 69#include <unistd.h> 70 | 71#include <pwd.h> 72#include <stdio.h> 73#include <stdlib.h> 74#include <string.h> 75#include <unistd.h> 76 |
71#include <netdb.h> 72#include <rpc/rpc.h> 73#include <rpc/pmap_prot.h> 74#include <rpcsvc/rquota.h> | 77const char *qfname = QUOTAFILENAME; 78const char *qfextension[] = INITQFNAMES; |
75 | 79 |
76char *qfname = QUOTAFILENAME; 77char *qfextension[] = INITQFNAMES; 78 | |
79struct quotause { 80 struct quotause *next; 81 long flags; 82 struct dqblk dqblk; 83 char fsname[MAXPATHLEN + 1]; 84}; 85#define FOUND 0x01 86 | 80struct quotause { 81 struct quotause *next; 82 long flags; 83 struct dqblk dqblk; 84 char fsname[MAXPATHLEN + 1]; 85}; 86#define FOUND 0x01 87 |
87static char *timeprt(time_t seconds); | 88static const char *timeprt(time_t seconds); |
88static struct quotause *getprivs(long id, int quotatype); | 89static struct quotause *getprivs(long id, int quotatype); |
89static void usage (); | 90static void usage(void); |
90static void showuid(u_long uid); 91static void showgid(u_long gid); 92static int alldigits(char *s); 93static void showusrname(char *name); 94static void showgrpname(char *name); | 91static void showuid(u_long uid); 92static void showgid(u_long gid); 93static int alldigits(char *s); 94static void showusrname(char *name); 95static void showgrpname(char *name); |
95static void showquotas(int type, u_long id, char *name); 96static void heading(int type, u_long id, char *name, char *tag); 97static char *timeprt(time_t seconds); | 96static void showquotas(int type, u_long id, const char *name); 97static void heading(int type, u_long id, const char *name, const char *tag); |
98static struct quotause *getprivs(long id, int quotatype); 99static int ufshasquota(struct fstab *fs, int type, char **qfnamep); | 98static struct quotause *getprivs(long id, int quotatype); 99static int ufshasquota(struct fstab *fs, int type, char **qfnamep); |
100static int getufsquota(struct statfs *fst, struct fstab *fs, 101 struct quotause *qup, long id, int quotatype); 102static int getnfsquota(struct statfs *fst, struct fstab *fs, 103 struct quotause *qup, long id, int quotatype); | 100static int getufsquota(struct fstab *fs, struct quotause *qup, long id, 101 int quotatype); 102static int getnfsquota(struct statfs *fst, struct quotause *qup, long id, 103 int quotatype); |
104static int callaurpc(char *host, int prognum, int versnum, int procnum, | 104static int callaurpc(char *host, int prognum, int versnum, int procnum, |
105 xdrproc_t inproc, char *in, xdrproc_t outproc, char *out); | 105 xdrproc_t inproc, char *in, xdrproc_t outproc, char *out); |
106static int alldigits(char *s); 107 108int qflag; 109int vflag; 110 111int | 106static int alldigits(char *s); 107 108int qflag; 109int vflag; 110 111int |
112main(argc, argv) 113 int argc; 114 char *argv[]; | 112main(int argc, char *argv[]) |
115{ 116 int ngroups; 117 gid_t mygid, gidset[NGROUPS]; 118 int i, gflag = 0, uflag = 0; 119 char ch; 120 121 while ((ch = getopt(argc, argv, "ugvq")) != -1) { 122 switch(ch) { --- 50 unchanged lines hidden (view full) --- 173 else 174 showgrpname(*argv); 175 } 176 } 177 return(0); 178} 179 180static void | 113{ 114 int ngroups; 115 gid_t mygid, gidset[NGROUPS]; 116 int i, gflag = 0, uflag = 0; 117 char ch; 118 119 while ((ch = getopt(argc, argv, "ugvq")) != -1) { 120 switch(ch) { --- 50 unchanged lines hidden (view full) --- 171 else 172 showgrpname(*argv); 173 } 174 } 175 return(0); 176} 177 178static void |
181usage() | 179usage(void) |
182{ 183 184 fprintf(stderr, "%s\n%s\n%s\n", 185 "usage: quota [-guqv]", 186 " quota [-qv] -u username ...", 187 " quota [-qv] -g groupname ..."); 188 exit(1); 189} 190 191/* 192 * Print out quotas for a specified user identifier. 193 */ 194static void | 180{ 181 182 fprintf(stderr, "%s\n%s\n%s\n", 183 "usage: quota [-guqv]", 184 " quota [-qv] -u username ...", 185 " quota [-qv] -g groupname ..."); 186 exit(1); 187} 188 189/* 190 * Print out quotas for a specified user identifier. 191 */ 192static void |
195showuid(uid) 196 u_long uid; | 193showuid(u_long uid) |
197{ 198 struct passwd *pwd = getpwuid(uid); 199 u_long myuid; | 194{ 195 struct passwd *pwd = getpwuid(uid); 196 u_long myuid; |
200 char *name; | 197 const char *name; |
201 202 if (pwd == NULL) 203 name = "(no account)"; 204 else 205 name = pwd->pw_name; 206 myuid = getuid(); 207 if (uid != myuid && myuid != 0) { 208 printf("quota: %s (uid %lu): permission denied\n", name, uid); 209 return; 210 } 211 showquotas(USRQUOTA, uid, name); 212} 213 214/* 215 * Print out quotas for a specifed user name. 216 */ 217static void | 198 199 if (pwd == NULL) 200 name = "(no account)"; 201 else 202 name = pwd->pw_name; 203 myuid = getuid(); 204 if (uid != myuid && myuid != 0) { 205 printf("quota: %s (uid %lu): permission denied\n", name, uid); 206 return; 207 } 208 showquotas(USRQUOTA, uid, name); 209} 210 211/* 212 * Print out quotas for a specifed user name. 213 */ 214static void |
218showusrname(name) 219 char *name; | 215showusrname(char *name) |
220{ 221 struct passwd *pwd = getpwnam(name); 222 u_long myuid; 223 224 if (pwd == NULL) { 225 warnx("%s: unknown user", name); 226 return; 227 } --- 4 unchanged lines hidden (view full) --- 232 } 233 showquotas(USRQUOTA, pwd->pw_uid, name); 234} 235 236/* 237 * Print out quotas for a specified group identifier. 238 */ 239static void | 216{ 217 struct passwd *pwd = getpwnam(name); 218 u_long myuid; 219 220 if (pwd == NULL) { 221 warnx("%s: unknown user", name); 222 return; 223 } --- 4 unchanged lines hidden (view full) --- 228 } 229 showquotas(USRQUOTA, pwd->pw_uid, name); 230} 231 232/* 233 * Print out quotas for a specified group identifier. 234 */ 235static void |
240showgid(gid) 241 u_long gid; | 236showgid(u_long gid) |
242{ 243 struct group *grp = getgrgid(gid); 244 int ngroups; 245 gid_t mygid, gidset[NGROUPS]; | 237{ 238 struct group *grp = getgrgid(gid); 239 int ngroups; 240 gid_t mygid, gidset[NGROUPS]; |
246 register int i; 247 char *name; | 241 int i; 242 const char *name; |
248 249 if (grp == NULL) 250 name = "(no entry)"; 251 else 252 name = grp->gr_name; 253 mygid = getgid(); 254 ngroups = getgroups(NGROUPS, gidset); 255 if (ngroups < 0) { --- 11 unchanged lines hidden (view full) --- 267 } 268 showquotas(GRPQUOTA, gid, name); 269} 270 271/* 272 * Print out quotas for a specifed group name. 273 */ 274static void | 243 244 if (grp == NULL) 245 name = "(no entry)"; 246 else 247 name = grp->gr_name; 248 mygid = getgid(); 249 ngroups = getgroups(NGROUPS, gidset); 250 if (ngroups < 0) { --- 11 unchanged lines hidden (view full) --- 262 } 263 showquotas(GRPQUOTA, gid, name); 264} 265 266/* 267 * Print out quotas for a specifed group name. 268 */ 269static void |
275showgrpname(name) 276 char *name; | 270showgrpname(char *name) |
277{ 278 struct group *grp = getgrnam(name); 279 int ngroups; 280 gid_t mygid, gidset[NGROUPS]; | 271{ 272 struct group *grp = getgrnam(name); 273 int ngroups; 274 gid_t mygid, gidset[NGROUPS]; |
281 register int i; | 275 int i; |
282 283 if (grp == NULL) { 284 warnx("%s: unknown group", name); 285 return; 286 } 287 mygid = getgid(); 288 ngroups = getgroups(NGROUPS, gidset); 289 if (ngroups < 0) { --- 9 unchanged lines hidden (view full) --- 299 grp->gr_gid); 300 return; 301 } 302 } 303 showquotas(GRPQUOTA, grp->gr_gid, name); 304} 305 306static void | 276 277 if (grp == NULL) { 278 warnx("%s: unknown group", name); 279 return; 280 } 281 mygid = getgid(); 282 ngroups = getgroups(NGROUPS, gidset); 283 if (ngroups < 0) { --- 9 unchanged lines hidden (view full) --- 293 grp->gr_gid); 294 return; 295 } 296 } 297 showquotas(GRPQUOTA, grp->gr_gid, name); 298} 299 300static void |
307showquotas(type, id, name) 308 int type; 309 u_long id; 310 char *name; | 301showquotas(int type, u_long id, const char *name) |
311{ | 302{ |
312 register struct quotause *qup; | 303 struct quotause *qup; |
313 struct quotause *quplist; | 304 struct quotause *quplist; |
314 char *msgi, *msgb, *nam; | 305 const char *msgi, *msgb; 306 const char *nam; |
315 int lines = 0; 316 static time_t now; 317 318 if (now == 0) 319 time(&now); 320 quplist = getprivs(id, type); 321 for (qup = quplist; qup; qup = qup->next) { 322 if (!vflag && 323 qup->dqblk.dqb_isoftlimit == 0 && 324 qup->dqblk.dqb_ihardlimit == 0 && 325 qup->dqblk.dqb_bsoftlimit == 0 && 326 qup->dqblk.dqb_bhardlimit == 0) 327 continue; 328 msgi = (char *)0; 329 if (qup->dqblk.dqb_ihardlimit && 330 qup->dqblk.dqb_curinodes >= qup->dqblk.dqb_ihardlimit) 331 msgi = "File limit reached on"; 332 else if (qup->dqblk.dqb_isoftlimit && | 307 int lines = 0; 308 static time_t now; 309 310 if (now == 0) 311 time(&now); 312 quplist = getprivs(id, type); 313 for (qup = quplist; qup; qup = qup->next) { 314 if (!vflag && 315 qup->dqblk.dqb_isoftlimit == 0 && 316 qup->dqblk.dqb_ihardlimit == 0 && 317 qup->dqblk.dqb_bsoftlimit == 0 && 318 qup->dqblk.dqb_bhardlimit == 0) 319 continue; 320 msgi = (char *)0; 321 if (qup->dqblk.dqb_ihardlimit && 322 qup->dqblk.dqb_curinodes >= qup->dqblk.dqb_ihardlimit) 323 msgi = "File limit reached on"; 324 else if (qup->dqblk.dqb_isoftlimit && |
333 qup->dqblk.dqb_curinodes >= qup->dqblk.dqb_isoftlimit) | 325 qup->dqblk.dqb_curinodes >= qup->dqblk.dqb_isoftlimit) { |
334 if (qup->dqblk.dqb_itime > now) 335 msgi = "In file grace period on"; 336 else 337 msgi = "Over file quota on"; | 326 if (qup->dqblk.dqb_itime > now) 327 msgi = "In file grace period on"; 328 else 329 msgi = "Over file quota on"; |
330 } |
|
338 msgb = (char *)0; 339 if (qup->dqblk.dqb_bhardlimit && 340 qup->dqblk.dqb_curblocks >= qup->dqblk.dqb_bhardlimit) 341 msgb = "Block limit reached on"; 342 else if (qup->dqblk.dqb_bsoftlimit && | 331 msgb = (char *)0; 332 if (qup->dqblk.dqb_bhardlimit && 333 qup->dqblk.dqb_curblocks >= qup->dqblk.dqb_bhardlimit) 334 msgb = "Block limit reached on"; 335 else if (qup->dqblk.dqb_bsoftlimit && |
343 qup->dqblk.dqb_curblocks >= qup->dqblk.dqb_bsoftlimit) | 336 qup->dqblk.dqb_curblocks >= qup->dqblk.dqb_bsoftlimit) { |
344 if (qup->dqblk.dqb_btime > now) 345 msgb = "In block grace period on"; 346 else 347 msgb = "Over block quota on"; | 337 if (qup->dqblk.dqb_btime > now) 338 msgb = "In block grace period on"; 339 else 340 msgb = "Over block quota on"; |
341 } |
|
348 if (qflag) { 349 if ((msgi != (char *)0 || msgb != (char *)0) && 350 lines++ == 0) 351 heading(type, id, name, ""); 352 if (msgi != (char *)0) 353 printf("\t%s %s\n", msgi, qup->fsname); 354 if (msgb != (char *)0) 355 printf("\t%s %s\n", msgb, qup->fsname); --- 31 unchanged lines hidden (view full) --- 387 continue; 388 } 389 } 390 if (!qflag && lines == 0) 391 heading(type, id, name, "none"); 392} 393 394static void | 342 if (qflag) { 343 if ((msgi != (char *)0 || msgb != (char *)0) && 344 lines++ == 0) 345 heading(type, id, name, ""); 346 if (msgi != (char *)0) 347 printf("\t%s %s\n", msgi, qup->fsname); 348 if (msgb != (char *)0) 349 printf("\t%s %s\n", msgb, qup->fsname); --- 31 unchanged lines hidden (view full) --- 381 continue; 382 } 383 } 384 if (!qflag && lines == 0) 385 heading(type, id, name, "none"); 386} 387 388static void |
395heading(type, id, name, tag) 396 int type; 397 u_long id; 398 char *name, *tag; | 389heading(int type, u_long id, const char *name, const char *tag) |
399{ 400 401 printf("Disk quotas for %s %s (%cid %lu): %s\n", qfextension[type], 402 name, *qfextension[type], id, tag); 403 if (!qflag && tag[0] == '\0') { 404 printf("%15s%8s %7s%8s%8s%8s %7s%8s%8s\n" 405 , "Filesystem" 406 , "usage" --- 6 unchanged lines hidden (view full) --- 413 , "grace" 414 ); 415 } 416} 417 418/* 419 * Calculate the grace period and return a printable string for it. 420 */ | 390{ 391 392 printf("Disk quotas for %s %s (%cid %lu): %s\n", qfextension[type], 393 name, *qfextension[type], id, tag); 394 if (!qflag && tag[0] == '\0') { 395 printf("%15s%8s %7s%8s%8s%8s %7s%8s%8s\n" 396 , "Filesystem" 397 , "usage" --- 6 unchanged lines hidden (view full) --- 404 , "grace" 405 ); 406 } 407} 408 409/* 410 * Calculate the grace period and return a printable string for it. 411 */ |
421static char * 422timeprt(seconds) 423 time_t seconds; | 412static const char * 413timeprt(time_t seconds) |
424{ 425 time_t hours, minutes; 426 static char buf[20]; 427 static time_t now; 428 429 if (now == 0) 430 time(&now); 431 if (now > seconds) --- 12 unchanged lines hidden (view full) --- 444 sprintf(buf, "%2ld", minutes); 445 return (buf); 446} 447 448/* 449 * Collect the requested quota information. 450 */ 451static struct quotause * | 414{ 415 time_t hours, minutes; 416 static char buf[20]; 417 static time_t now; 418 419 if (now == 0) 420 time(&now); 421 if (now > seconds) --- 12 unchanged lines hidden (view full) --- 434 sprintf(buf, "%2ld", minutes); 435 return (buf); 436} 437 438/* 439 * Collect the requested quota information. 440 */ 441static struct quotause * |
452getprivs(id, quotatype) 453 register long id; 454 int quotatype; | 442getprivs(long id, int quotatype) |
455{ | 443{ |
456 register struct quotause *qup, *quptail; 457 register struct fstab *fs; | 444 struct quotause *qup, *quptail; 445 struct fstab *fs; |
458 struct quotause *quphead; 459 struct statfs *fst; 460 int nfst, i; 461 462 qup = quphead = (struct quotause *)0; 463 464 nfst = getmntinfo(&fst, MNT_WAIT); 465 if (nfst == 0) 466 errx(2, "no filesystems mounted!"); 467 setfsent(); 468 for (i=0; i<nfst; i++) { 469 if (qup == NULL) { 470 if ((qup = (struct quotause *)malloc(sizeof *qup)) 471 == NULL) 472 errx(2, "out of memory"); 473 } 474 if (strcmp(fst[i].f_fstypename, "nfs") == 0) { | 446 struct quotause *quphead; 447 struct statfs *fst; 448 int nfst, i; 449 450 qup = quphead = (struct quotause *)0; 451 452 nfst = getmntinfo(&fst, MNT_WAIT); 453 if (nfst == 0) 454 errx(2, "no filesystems mounted!"); 455 setfsent(); 456 for (i=0; i<nfst; i++) { 457 if (qup == NULL) { 458 if ((qup = (struct quotause *)malloc(sizeof *qup)) 459 == NULL) 460 errx(2, "out of memory"); 461 } 462 if (strcmp(fst[i].f_fstypename, "nfs") == 0) { |
475 if (getnfsquota(&fst[i], NULL, qup, id, quotatype) | 463 if (getnfsquota(&fst[i], qup, id, quotatype) |
476 == 0) 477 continue; 478 } else if (strcmp(fst[i].f_fstypename, "ufs") == 0) { 479 /* 480 * XXX 481 * UFS filesystems must be in /etc/fstab, and must 482 * indicate that they have quotas on (?!) This is quite 483 * unlike SunOS where quotas can be enabled/disabled 484 * on a filesystem independent of /etc/fstab, and it 485 * will still print quotas for them. 486 */ 487 if ((fs = getfsspec(fst[i].f_mntfromname)) == NULL) 488 continue; | 464 == 0) 465 continue; 466 } else if (strcmp(fst[i].f_fstypename, "ufs") == 0) { 467 /* 468 * XXX 469 * UFS filesystems must be in /etc/fstab, and must 470 * indicate that they have quotas on (?!) This is quite 471 * unlike SunOS where quotas can be enabled/disabled 472 * on a filesystem independent of /etc/fstab, and it 473 * will still print quotas for them. 474 */ 475 if ((fs = getfsspec(fst[i].f_mntfromname)) == NULL) 476 continue; |
489 if (getufsquota(&fst[i], fs, qup, id, quotatype) == 0) | 477 if (getufsquota(fs, qup, id, quotatype) == 0) |
490 continue; 491 } else 492 continue; 493 strcpy(qup->fsname, fst[i].f_mntonname); 494 if (quphead == NULL) 495 quphead = qup; 496 else 497 quptail->next = qup; --- 6 unchanged lines hidden (view full) --- 504 endfsent(); 505 return (quphead); 506} 507 508/* 509 * Check to see if a particular quota is to be enabled. 510 */ 511static int | 478 continue; 479 } else 480 continue; 481 strcpy(qup->fsname, fst[i].f_mntonname); 482 if (quphead == NULL) 483 quphead = qup; 484 else 485 quptail->next = qup; --- 6 unchanged lines hidden (view full) --- 492 endfsent(); 493 return (quphead); 494} 495 496/* 497 * Check to see if a particular quota is to be enabled. 498 */ 499static int |
512ufshasquota(fs, type, qfnamep) 513 register struct fstab *fs; 514 int type; 515 char **qfnamep; | 500ufshasquota(struct fstab *fs, int type, char **qfnamep) |
516{ 517 static char initname, usrname[100], grpname[100]; 518 static char buf[BUFSIZ]; 519 char *opt, *cp; 520 521 if (!initname) { 522 sprintf(usrname, "%s%s", qfextension[USRQUOTA], qfname); 523 sprintf(grpname, "%s%s", qfextension[GRPQUOTA], qfname); --- 15 unchanged lines hidden (view full) --- 539 return (1); 540 } 541 (void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]); 542 *qfnamep = buf; 543 return (1); 544} 545 546static int | 501{ 502 static char initname, usrname[100], grpname[100]; 503 static char buf[BUFSIZ]; 504 char *opt, *cp; 505 506 if (!initname) { 507 sprintf(usrname, "%s%s", qfextension[USRQUOTA], qfname); 508 sprintf(grpname, "%s%s", qfextension[GRPQUOTA], qfname); --- 15 unchanged lines hidden (view full) --- 524 return (1); 525 } 526 (void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]); 527 *qfnamep = buf; 528 return (1); 529} 530 531static int |
547getufsquota(fst, fs, qup, id, quotatype) 548 struct statfs *fst; 549 struct fstab *fs; 550 struct quotause *qup; 551 long id; 552 int quotatype; | 532getufsquota(struct fstab *fs, struct quotause *qup, long id, int quotatype) |
553{ 554 char *qfpathname; 555 int fd, qcmd; 556 557 qcmd = QCMD(Q_GETQUOTA, quotatype); 558 if (!ufshasquota(fs, quotatype, &qfpathname)) 559 return (0); 560 --- 19 unchanged lines hidden (view full) --- 580 return (0); 581 } 582 close(fd); 583 } 584 return (1); 585} 586 587static int | 533{ 534 char *qfpathname; 535 int fd, qcmd; 536 537 qcmd = QCMD(Q_GETQUOTA, quotatype); 538 if (!ufshasquota(fs, quotatype, &qfpathname)) 539 return (0); 540 --- 19 unchanged lines hidden (view full) --- 560 return (0); 561 } 562 close(fd); 563 } 564 return (1); 565} 566 567static int |
588getnfsquota(fst, fs, qup, id, quotatype) 589 struct statfs *fst; 590 struct fstab *fs; 591 struct quotause *qup; 592 long id; 593 int quotatype; | 568getnfsquota(struct statfs *fst, struct quotause *qup, long id, int quotatype) |
594{ 595 struct getquota_args gq_args; 596 struct getquota_rslt gq_rslt; 597 struct dqblk *dqp = &qup->dqblk; 598 struct timeval tv; 599 char *cp; 600 601 if (fst->f_flags & MNT_LOCAL) --- 66 unchanged lines hidden (view full) --- 668 warnx("bad rpc result, host: %s", fst->f_mntfromname); 669 break; 670 } 671 *cp = ':'; 672 return (0); 673} 674 675static int | 569{ 570 struct getquota_args gq_args; 571 struct getquota_rslt gq_rslt; 572 struct dqblk *dqp = &qup->dqblk; 573 struct timeval tv; 574 char *cp; 575 576 if (fst->f_flags & MNT_LOCAL) --- 66 unchanged lines hidden (view full) --- 643 warnx("bad rpc result, host: %s", fst->f_mntfromname); 644 break; 645 } 646 *cp = ':'; 647 return (0); 648} 649 650static int |
676callaurpc(host, prognum, versnum, procnum, inproc, in, outproc, out) 677 char *host; 678 xdrproc_t inproc, outproc; 679 char *in, *out; 680 int prognum, versnum, procnum; | 651callaurpc(char *host, int prognum, int versnum, int procnum, 652 xdrproc_t inproc, char *in, xdrproc_t outproc, char *out) |
681{ 682 struct sockaddr_in server_addr; 683 enum clnt_stat clnt_stat; 684 struct hostent *hp; 685 struct timeval timeout, tottimeout; 686 687 CLIENT *client = NULL; | 653{ 654 struct sockaddr_in server_addr; 655 enum clnt_stat clnt_stat; 656 struct hostent *hp; 657 struct timeval timeout, tottimeout; 658 659 CLIENT *client = NULL; |
688 int socket = RPC_ANYSOCK; | 660 int sock = RPC_ANYSOCK; |
689 690 if ((hp = gethostbyname(host)) == NULL) 691 return ((int) RPC_UNKNOWNHOST); 692 timeout.tv_usec = 0; 693 timeout.tv_sec = 6; 694 bcopy(hp->h_addr, &server_addr.sin_addr, | 661 662 if ((hp = gethostbyname(host)) == NULL) 663 return ((int) RPC_UNKNOWNHOST); 664 timeout.tv_usec = 0; 665 timeout.tv_sec = 6; 666 bcopy(hp->h_addr, &server_addr.sin_addr, |
695 MIN(hp->h_length,sizeof(server_addr.sin_addr))); | 667 MIN(hp->h_length,(int)sizeof(server_addr.sin_addr))); |
696 server_addr.sin_family = AF_INET; 697 server_addr.sin_port = 0; 698 699 if ((client = clntudp_create(&server_addr, prognum, | 668 server_addr.sin_family = AF_INET; 669 server_addr.sin_port = 0; 670 671 if ((client = clntudp_create(&server_addr, prognum, |
700 versnum, timeout, &socket)) == NULL) | 672 versnum, timeout, &sock)) == NULL) |
701 return ((int) rpc_createerr.cf_stat); 702 703 client->cl_auth = authunix_create_default(); 704 tottimeout.tv_sec = 25; 705 tottimeout.tv_usec = 0; 706 clnt_stat = clnt_call(client, procnum, inproc, in, 707 outproc, out, tottimeout); 708 709 return ((int) clnt_stat); 710} 711 712static int | 673 return ((int) rpc_createerr.cf_stat); 674 675 client->cl_auth = authunix_create_default(); 676 tottimeout.tv_sec = 25; 677 tottimeout.tv_usec = 0; 678 clnt_stat = clnt_call(client, procnum, inproc, in, 679 outproc, out, tottimeout); 680 681 return ((int) clnt_stat); 682} 683 684static int |
713alldigits(s) 714 register char *s; | 685alldigits(char *s) |
715{ | 686{ |
716 register c; | 687 int c; |
717 718 c = *s++; 719 do { 720 if (!isdigit(c)) 721 return (0); 722 } while ((c = *s++)); 723 return (1); 724} | 688 689 c = *s++; 690 do { 691 if (!isdigit(c)) 692 return (0); 693 } while ((c = *s++)); 694 return (1); 695} |