Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Jan 2007 02:12:00 -0600
From:      "Scot Hetzel" <swhetzel@gmail.com>
To:        freebsd-emulation@freebsd.org
Subject:   Re: linuxolator: proc/filesystems and sysfs function implementations
Message-ID:  <790a9fff0701060012x40063f48pc842510b082df5a5@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
While working on the proc/filesystems implementation, I noticed that
the sysfs function also returns with similar results.  I have
implemented all 3 options used in the sysfs function, and they seem to
pass most of the LTP tests (sysfs01-04, 06).  sysfs05 crashes the
system when it gets to the test with an invalid address.

Currently, I am having a problem in returning EFAULT on an invalid
address, a condensed version of the code, where I need this check is:

int
linux_sysfs(struct thread *td, struct linux_sysfs_args *args)
{
   unsigned int index;
   char *name;

   switch (args->option) {
      case 1:
          name = (char *)(uintptr_t)args->arg1;
          /* XXX: check if name is invalid and return EFAULT */
           :
           /* find the index for a given name */
           break;
     case  2:
           index = args->arg1;
           buf = (char *)(uintptr_t)args->arg2;
           /* XXX: check if buf is invalid and return EFAULT */
          :
          /* find the fs name using the index */
          :
          /* XXX: Will this return EFAULT with an invalid buf [(char *)-1]? */
          error = copyout(vfsp->vfc_name, buf, len);
          break;
    case 3:
           /* count the number of available fs */
           :
           break;
    }
    return (error);
}

This implementation is using  TAILQ_FOREACH(vfsp, &vfsconf, vfc_list)
to search the filesystem list (as suggested by Kostik).

I also re-implemented the patch to linprocfs to use
TAILQ_FOREACH(vfsp, &vfsconf, vfc_list), and implemented the
freebsd_to_linux_fs function (translates a freebsd fs name to a linux
fs name) in sys/compat/linprocfs/linprocfs.c.

This function is needed by the sysfs implementation, and was wondering
where the translation function, and the structure it returns should be
placed so that it is accessable to both implementations (linux_sysfs,
and linprocfs_dofilesystems).

struct l_file_system_type {
        const char *name;
        int fs_flags;
};

#define FS_REQUIRES_DEV 1

static void *
freebsd_to_linux_fs(char *name, struct l_file_system_type *fs)
{
        fs->name = name;
        fs->fs_flags = FS_REQUIRES_DEV;
        :
        /* Does fs require a dev entry? */
        :
       /* Translate FreeBSD -> Linux fs name */
       :
}

Scot
-- 
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?790a9fff0701060012x40063f48pc842510b082df5a5>