df.c (5eb43ac2f70729e688f03999a2f66d1272e14a6d) | df.c (5965373e69ca208cedd8ede9716ef0d58e6c3434) |
---|---|
1/* 2 * Copyright (c) 1980, 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 477 unchanged lines hidden (view full) --- 486 "usage: df [-b | -H | -h | -k | -m | -P] [-ailn] [-t type] [file | filesystem ...]\n"); 487 exit(EX_USAGE); 488} 489 490static char * 491makenetvfslist(void) 492{ 493 char *str, *strptr, **listptr; | 1/* 2 * Copyright (c) 1980, 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 477 unchanged lines hidden (view full) --- 486 "usage: df [-b | -H | -h | -k | -m | -P] [-ailn] [-t type] [file | filesystem ...]\n"); 487 exit(EX_USAGE); 488} 489 490static char * 491makenetvfslist(void) 492{ 493 char *str, *strptr, **listptr; |
494 int mib[3], maxvfsconf, cnt=0, i; 495 size_t miblen; 496 struct ovfsconf *ptr; | 494 struct xvfsconf *xvfsp; 495 size_t buflen; 496 int cnt, i, maxvfsconf; |
497 | 497 |
498 mib[0] = CTL_VFS; mib[1] = VFS_GENERIC; mib[2] = VFS_MAXTYPENUM; 499 miblen=sizeof(maxvfsconf); 500 if (sysctl(mib, (unsigned int)(sizeof(mib) / sizeof(mib[0])), 501 &maxvfsconf, &miblen, NULL, 0)) { 502 warnx("sysctl failed"); | 498 if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0) { 499 warn("sysctl(vfs.conflist)"); |
503 return (NULL); 504 } | 500 return (NULL); 501 } |
502 xvfsp = malloc(buflen); 503 if (xvfsp == NULL) { 504 warnx("malloc failed"); 505 return (NULL); 506 } 507 if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0) { 508 warn("sysctl(vfs.conflist)"); 509 return (NULL); 510 } 511 maxvfsconf = buflen / sizeof(struct xvfsconf); |
|
505 506 if ((listptr = malloc(sizeof(char*) * maxvfsconf)) == NULL) { 507 warnx("malloc failed"); 508 return (NULL); 509 } 510 | 512 513 if ((listptr = malloc(sizeof(char*) * maxvfsconf)) == NULL) { 514 warnx("malloc failed"); 515 return (NULL); 516 } 517 |
511 for (ptr = getvfsent(); ptr; ptr = getvfsent()) 512 if (ptr->vfc_flags & VFCF_NETWORK) { 513 listptr[cnt++] = strdup(ptr->vfc_name); | 518 for (cnt = 0, i = 0; i < maxvfsconf; i++) { 519 if (xvfsp->vfc_flags & VFCF_NETWORK) { 520 listptr[cnt++] = strdup(xvfsp->vfc_name); |
514 if (listptr[cnt-1] == NULL) { 515 warnx("malloc failed"); 516 return (NULL); 517 } 518 } | 521 if (listptr[cnt-1] == NULL) { 522 warnx("malloc failed"); 523 return (NULL); 524 } 525 } |
526 xvfsp++; 527 } |
|
519 520 if (cnt == 0 || 521 (str = malloc(sizeof(char) * (32 * cnt + cnt + 2))) == NULL) { 522 if (cnt > 0) 523 warnx("malloc failed"); 524 free(listptr); 525 return (NULL); 526 } --- 13 unchanged lines hidden --- | 528 529 if (cnt == 0 || 530 (str = malloc(sizeof(char) * (32 * cnt + cnt + 2))) == NULL) { 531 if (cnt > 0) 532 warnx("malloc failed"); 533 free(listptr); 534 return (NULL); 535 } --- 13 unchanged lines hidden --- |