On Tue, May 22, 2012 at 09:48:42AM -0700, Matthew Dempsky wrote:
> On Tue, May 22, 2012 at 9:42 AM, Paul Irofti <p...@irofti.net> wrote:
> >> > +       /*
> >> > +        * Convert BSD filesystem names to Linux filesystem type numbers
> >> > +        * where possible.  Linux statfs uses a value of -1 to indicate
> >> > +        * an unsupported field.
> >> > +        */
> >> > +       if (!strcmp(bsp->f_fstypename, MOUNT_FFS) ||
> >> > +           !strcmp(bsp->f_fstypename, MOUNT_MFS))
> >> > +               lsp->l_ftype = 0x11954;
> >> > +       else if (!strcmp(bsp->f_fstypename, MOUNT_NFS))
> >> > +               lsp->l_ftype = 0x6969;
> >> > +       else if (!strcmp(bsp->f_fstypename, MOUNT_MSDOS))
> >> > +               lsp->l_ftype = 0x4d44;
> >> > +       else if (!strcmp(bsp->f_fstypename, MOUNT_PROCFS))
> >> > +               lsp->l_ftype = 0x9fa0;
> >> > +       else if (!strcmp(bsp->f_fstypename, MOUNT_EXT2FS))
> >> > +               lsp->l_ftype = 0xef53;
> >> > +       else if (!strcmp(bsp->f_fstypename, MOUNT_CD9660))
> >> > +               lsp->l_ftype = 0x9660;
> >> > +       else if (!strcmp(bsp->f_fstypename, MOUNT_NCPFS))
> >> > +               lsp->l_ftype = 0x6969;
> >> > +       else
> >> > +               lsp->l_ftype = -1;
> >>
> >> Can this code go into a separate function so we don't have to
> >> duplicate it for both statfs and statfs64?
> >
> > I thought about it. Best would be a macro, but I hate C macro's.
> 
> What about a function like this:
> 
> long
> bsd_to_linux_filesystem_map(const char *fstypename)
> {
>         if (!strcmp(fstypename, MOUNT_FFS) || !strcmp(fstypename, MOUNT_MFS))
>                 return (0x11954);
>         else if (!strcmp(fstypename, MOUNT_NFS))
>                 return (0x6969);
>         [...]
>         else
>                 return (-1);
> }
> 
> (I'm assuming linux_statfs64's l_ftype is also a long.)


I keep it as an int now because things seem really stupid from what I'm
reading in the linux kernel:

http://tinyurl.com/chnpxnz

Reply via email to