Mac OS X 10.4: getattrlist() to know the File-system type

This is a discussion on Mac OS X 10.4: getattrlist() to know the File-system type within the Linux Programming forums, part of the Platform Specific Boards category; Hello All, I need to identify via a program the file-system types of all mounted volumes. There are 2 options ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    22

    Mac OS X 10.4: getattrlist() to know the File-system type

    Hello All,
    I need to identify via a program the file-system types of all mounted volumes. There are 2 options : using getattrlist() or getmntinfo().

    With getattrlist() ATTR_VOL_FSTYPE gives the file-system type as an unsigned long. From this how do I know if the volume is HFS/HFS+/UFS etc.

    Code:
    #include<stdio.h>
    #include<sys/param.h>
    #include<sys/ucred.h>
    #include<sys/mount.h>
    #include<errno.h>
    #include<sys/types.h>
    #include<string.h>
    #include<errno.h>
    
    struct AttrBuf
    {
            unsigned long length;
            unsigned long fstype;
            unsigned long fssign;
    };
    
    int main()
    {
            int count, i,errno,j;
            struct statfs *mntbufp;
            struct attrlist attrList;
            struct AttrBuf attrbuf;
    
            unsigned long signature;
            char sign[5];
    
            memset(&attrList, 0, sizeof(attrList));
            memset(&attrbuf, 0, sizeof(attrbuf));
    
            attrList.bitmapcount = ATTR_BIT_MAP_COUNT ;
            attrList.volattr = ATTR_VOL_INFO | ATTR_VOL_FSTYPE | ATTR_VOL_SIGNATURE ;
    
            if((count = getmntinfo(&mntbufp, MNT_NOWAIT)) == 0)
                    perror("getmntinfo() failed\n");
            else
            {
                    for(i=0;i<count;i++)
                    {
                            printf("-------------------------------------------------------------\n");
                            printf("Mount point = %s\n",mntbufp[i].f_mntonname);
                            printf("Filesystem type = %s\n",mntbufp[i].f_fstypename);
                            if(getattrlist(mntbufp[i].f_mntonname , &attrList, &attrbuf, sizeof(attrbuf), FSOPT_NOFOLLOW) == -1)
                                    perror("getattrlist() failed\n");
                            printf("FS type = %lu\n",attrbuf.fstype);
                            printf("Volume signature = %lu\n",attrbuf.fssign);
                    }
            }
    
            return 0;
    }
    This prints HFS+ volumes as FS type=17. Is this constant or may change? Is there some sort of mapping from this number to a file-system type?

    When I use getmntinfo() to print the file-system type, it prints HFS+ volumes as HFS. Any solution for this?

    Thanks

  2. #2
    Registered User
    Join Date
    Aug 2008
    Posts
    22
    Hello people, need some help here..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 02:19 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21