$NetBSD$
Fixes segmentation fault on NetBSD
old
|
new
|
|
54 | 54 | |
55 | 55 | #ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ |
56 | 56 | #include <sys/statvfs.h> |
| 57 | #define statfs statvfs |
57 | 58 | #endif |
58 | 59 | |
59 | 60 | #ifdef MOUNTED_GETMNT /* Ultrix. */ |
… |
… |
read_filesystem_list (int need_fs_type, |
364 | 365 | #endif /* MOUNTED */ |
365 | 366 | #endif /* MOUNTED_GETMNTENT1 */ |
366 | 367 | |
367 | | #ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ |
| 368 | #if defined(MOUNTED_GETMNTINFO) || defined(MOUNTED_GETMNTINFO2) |
| 369 | /* 4.4BSD and NetBSD>=3 */ |
368 | 370 | { |
369 | 371 | struct statfs *fsp; |
370 | 372 | int entries; |
… |
… |
read_filesystem_list (int need_fs_type, |
376 | 378 | me = (struct mount_entry *) malloc (sizeof (struct mount_entry)); |
377 | 379 | me->me_devname = strdup (fsp->f_mntfromname); |
378 | 380 | me->me_mountdir = strdup (fsp->f_mntonname); |
379 | | #ifdef HAVE_STRUCT_STATFS_F_FSTYPENAME |
| 381 | #if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(MOUNTED_GETMNTINFO2) |
380 | 382 | me->me_type = strdup (fsp->f_fstypename); |
381 | 383 | #else |
382 | 384 | me->me_type = fstype_to_string (fsp->f_type); |
… |
… |
read_filesystem_list (int need_fs_type, |
392 | 394 | } |
393 | 395 | #endif /* MOUNTED_GETMNTINFO */ |
394 | 396 | |
395 | | #ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ |
396 | | { |
397 | | struct statvfs *fsp; |
398 | | int entries; |
399 | | |
400 | | entries = getmntinfo (&fsp, MNT_NOWAIT); |
401 | | if (entries < 0) |
402 | | return NULL; |
403 | | for (; entries-- > 0; fsp++) { |
404 | | me = (struct mount_entry *) malloc (sizeof (struct mount_entry)); |
405 | | me->me_devname = strdup (fsp->f_mntfromname); |
406 | | me->me_mountdir = strdup (fsp->f_mntonname); |
407 | | me->me_type = strdup (fsp->f_fstypename); |
408 | | me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ |
409 | | |
410 | | /* Add to the linked list. */ |
411 | | mtail->me_next = me; |
412 | | mtail = me; |
413 | | } |
414 | | } |
415 | | #endif /* MOUNTED_GETMNTINFO2 */ |
416 | | |
417 | 397 | #ifdef MOUNTED_GETMNT /* Ultrix. */ |
418 | 398 | { |
419 | 399 | int offset = 0; |