Ticket #2425: mc.patch

File mc.patch, 1.8 KB (added by cheusov, 14 years ago)
  • src/mountlist.c

    $NetBSD$
    Fixes segmentation fault on NetBSD
    old new  
    5454 
    5555#ifdef MOUNTED_GETMNTINFO2      /* NetBSD 3.0.  */ 
    5656#include <sys/statvfs.h> 
     57#define statfs statvfs 
    5758#endif 
    5859 
    5960#ifdef MOUNTED_GETMNT           /* Ultrix.  */ 
    read_filesystem_list (int need_fs_type,  
    364365#endif /* MOUNTED */ 
    365366#endif /* MOUNTED_GETMNTENT1 */ 
    366367 
    367 #ifdef MOUNTED_GETMNTINFO       /* 4.4BSD.  */ 
     368#if defined(MOUNTED_GETMNTINFO) || defined(MOUNTED_GETMNTINFO2) 
     369/* 4.4BSD and NetBSD>=3 */ 
    368370    { 
    369371        struct statfs *fsp; 
    370372        int entries; 
    read_filesystem_list (int need_fs_type,  
    376378            me = (struct mount_entry *) malloc (sizeof (struct mount_entry)); 
    377379            me->me_devname = strdup (fsp->f_mntfromname); 
    378380            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) 
    380382            me->me_type = strdup (fsp->f_fstypename); 
    381383#else 
    382384            me->me_type = fstype_to_string (fsp->f_type); 
    read_filesystem_list (int need_fs_type,  
    392394    } 
    393395#endif /* MOUNTED_GETMNTINFO */ 
    394396 
    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  
    417397#ifdef MOUNTED_GETMNT           /* Ultrix.  */ 
    418398    { 
    419399        int offset = 0;