bug-hurd
[Top][All Lists]
Advanced

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

fatfs locking


From: marco
Subject: fatfs locking
Date: Sun, 31 Mar 2002 23:27:10 +0200 (CEST)

Hi,

Currently I'm working on fatfs and I ran into a little problem:

FAT doesn't have inodes, so fatfs has to lock the node of the
directory that contains the node for which diskfs_cached_lookup is
called. diskfs_cached_lookup is called by diskfs, before that call the
directory node is locked or unlocked by diskfs and fatfs doesn't know if
diskfs locked the node or if it didn't. Because of this fatfs doesn't
know if it should lock the directory node.

This can be solved by changing the diskfs_cached_lookup function. I think
the best way to do this is by adding a parameter to diskfs_cached_lookup
which can be used by functions in diskfs to tell the translator if the
directorynode is locked.

Here is a little patch which does exactly what I discribed:

Common subdirectories: libdiskfs.old/CVS and libdiskfs/CVS
diff -u -p libdiskfs.old/diskfs.h libdiskfs/diskfs.h
--- libdiskfs.old/diskfs.h      Sun Mar 31 20:50:22 2002
+++ libdiskfs/diskfs.h  Sat Mar 30 16:50:01 2002
@@ -748,7 +748,7 @@ error_t diskfs_dirremove (struct node *d
                          const char *name, struct dirstat *ds);

 /* Return the node corresponding to CACHE_ID in *NPP. */
-error_t diskfs_cached_lookup (int cache_id, struct node **npp);
+error_t diskfs_cached_lookup (int cache_id, struct node **npp, int
dir_locked);
 /* Create a new node. Give it MODE; if that includes IFDIR, also
    initialize `.' and `..' in the new directory.  Return the node in NPP.
diff -u -p libdiskfs.old/fsys-getfile.c libdiskfs/fsys-getfile.c
--- libdiskfs.old/fsys-getfile.c        Sun Mar 31 20:50:24 2002
+++ libdiskfs/fsys-getfile.c    Sat Mar 30 16:51:00 2002
@@ -55,7 +55,7 @@ diskfs_S_fsys_getfile (mach_port_t fsys,

   f = (const union diskfs_fhandle *) handle;

-  err = diskfs_cached_lookup (f->data.cache_id, &node);
+  err = diskfs_cached_lookup (f->data.cache_id, &node, 0);
   if (err)
     {
       ports_port_deref (pt);
diff -u -p libdiskfs.old/name-cache.c libdiskfs/name-cache.c
--- libdiskfs.old/name-cache.c  Sun Mar 31 20:50:27 2002
+++ libdiskfs/name-cache.c      Sat Mar 30 16:50:37 2002
@@ -238,7 +238,7 @@ diskfs_check_lookup_cache (struct node *
          if (name[0] == '.' && name[1] == '.' && name[2] == '\0')
            {
              mutex_unlock (&dir->lock);
-             err = diskfs_cached_lookup (id, &np);
+             err = diskfs_cached_lookup (id, &np, 0);
              mutex_lock (&dir->lock);

              /* In the window where DP was unlocked, we might
@@ -253,7 +253,7 @@ diskfs_check_lookup_cache (struct node *
                }
            }
          else
-           err = diskfs_cached_lookup (id, &np);
+           err = diskfs_cached_lookup (id, &np, 1);
          return err ? 0 : np;
        }
     }


--------------------
Marco Gerards







reply via email to

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