bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fatfs patches


From: M. Gerards
Subject: fatfs patches
Date: Sat, 26 Apr 2003 23:37:55 +0200
User-agent: Internet Messaging Program (IMP) 3.1

Hi,

I've found a bug in the diskfs_get_directs function of fatfs. This function does
not work for FAT32, the included patch fixes this problem.

The other included patch fixed the deadlock problem for fatfs by breaking NFS
support (NFSD can't access the filesystem anymore, but I guess this is better
than an immidiate deadlock ;)).

Both patches can be found below including the appropiate ChangeLog entry.

Thanks,
Marco Gerards

2003-04-26  Marco Gerards  <metgerards@student.han.nl>
        * dir.c (diskfs_get_directs): Fix the . and .. emulation for the
        rootnode on FAT32 filesystems.


--- fatfs.old/dir.c     2002-12-03 21:52:59.000000000 +0100
+++ fatfs/dir.c 2003-04-25 21:38:00.000000000 +0200
@@ -839,7 +839,7 @@ diskfs_get_directs (struct node *dp,
         filenames).  */
       if ((char)ep->name[0] == FAT_DIR_NAME_DELETED
          || (ep->attribute & FAT_DIR_ATTR_LABEL))
-         i--;
+       i--;
       bufp = bufp + FAT_DIR_REC_LEN;
     }

@@ -857,13 +857,10 @@ diskfs_get_directs (struct node *dp,

       /* The root directory in FAT file systems doesn't contain
         entries for DOT and DOTDOT, they are special cased below.  */
-      if (dp == diskfs_root_node && i < 2)
-       {
-         if (i == 0)
-           ep = &dot;
-         else
-           ep = &dotdot;
-       }
+      if (dp == diskfs_root_node && (i + entry == 0))
+       ep = &dot;
+      else if (dp == diskfs_root_node && (i + entry == 1))
+       ep = &dotdot;
       else
        ep = (struct dirrect *) bufp;

@@ -931,7 +928,7 @@ diskfs_get_directs (struct node *dp,

       /* And move along.  */
       datap = datap + reclen;
-      if (!(dp == diskfs_root_node && i < 2))
+      if (!(dp == diskfs_root_node && (i + entry < 2)))
        bufp = bufp + FAT_DIR_REC_LEN;
       i++;
     }

2003-04-26  Marco Gerards  <metgerards@student.han.nl>
        * inode.c (read_node): Use ifind instead of diskfs_cached_lookup
        and do not use diskfs_nput anymore.
        * main.c (diskfs_S_fsys_getfile): New function.

diff -up fatfs.old/inode.c fatfs/inode.c
--- fatfs.old/inode.c   2002-12-03 21:52:59.000000000 +0100
+++ fatfs/inode.c       2003-04-25 21:59:00.000000000 +0200
@@ -1,5 +1,5 @@
 /* inode.c - Inode management routines.
-   Copyright (C) 1994,95,96,97,98,99, 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1994,95,96,97,98,99,2000,02,03 Free Software Foundation, Inc.
    Modified for fatfs by Marcus Brinkmann <marcus@gnu.org>

    This file is part of the GNU Hurd.
@@ -273,18 +273,13 @@ read_node (struct node *np, vm_address_t
     {
       if (buf == 0)
        {
-         err = diskfs_cached_lookup (vk.dir_inode, &dp);
-         if (err)
-           return err;
+         dp = ifind (vk.dir_inode);

          /* Map in the directory contents. */
          memobj = diskfs_get_filemap (dp, prot);

          if (memobj == MACH_PORT_NULL)
-           {
-             diskfs_nput (dp);
              return errno;
-           }

          buflen = round_page (dp->dn_stat.st_size);
          err = vm_map (mach_task_self (),
@@ -347,8 +342,6 @@ read_node (struct node *np, vm_address_t
            {
              if (our_buf && buf)
                munmap ((caddr_t) buf, buflen);
-             if (dp)
-               diskfs_nput (dp);
              return err;
            }
          st->st_size = np->allocsize;
@@ -384,8 +377,6 @@ read_node (struct node *np, vm_address_t

   if (our_buf && buf)
     munmap ((caddr_t) buf, buflen);
-  if (dp)
-    diskfs_nput (dp);
   return 0;
 }

diff -up fatfs.old/main.c fatfs/main.c
--- fatfs.old/main.c    2002-12-03 21:52:59.000000000 +0100
+++ fatfs/main.c        2003-04-25 21:44:00.000000000 +0200
@@ -1,5 +1,5 @@
 /* main.c - FAT filesystem.
-   Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
    Written by Thomas Bushnell, n/BSG and Marcus Brinkmann.

    This file is part of the GNU Hurd.
@@ -263,3 +263,14 @@ diskfs_readonly_changed (int readonly)
   abort ();
 }

+/* Break NFS support to get read support.  */
+error_t
+diskfs_S_fsys_getfile (mach_port_t fsys,
+                      mach_port_t reply, mach_msg_type_name_t reply_type,
+                      uid_t *uids, mach_msg_type_number_t nuids,
+                      gid_t *gids, mach_msg_type_number_t ngids,
+                      char *handle, mach_msg_type_number_t handle_len,
+                      mach_port_t *file, mach_msg_type_name_t *file_type)
+{
+  return EOPNOTSUPP;
+}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]