commit-hurd
[Top][All Lists]
Advanced

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

hurd/fatfs ChangeLog Makefile dir.c fat.c main.c


From: Marcus Brinkmann
Subject: hurd/fatfs ChangeLog Makefile dir.c fat.c main.c
Date: Sat, 02 Aug 2003 17:32:53 -0400

CVSROOT:        /cvsroot/hurd
Module name:    hurd
Branch:         
Changes by:     Marcus Brinkmann <address@hidden>       03/08/02 17:32:52

Modified files:
        fatfs          : ChangeLog Makefile dir.c fat.c main.c 

Log message:
        2003-08-01  Marco Gerards  <address@hidden>
        
        * node-create.c: New file.
        * Makefile (SRCS): Added node-created.c.
        * dir.c: Include <hurd/fsys.h>.
        (diskfs_direnter_hard): Initialize a new block with zeros. Enter
        direntry and setup the virtual  inode. Also handle directories
        correctly.
        (diskfs_rewrite_hard): Function rewritten.
        (diskfs_dirempty): Change logic to test if a file was deleted.
        * fat.c (fat_extend_chain): Unlock spin_lock when returning from
        function. Set dn->last to 0 when deallocating the complete
        file. Update dn->last when not deallocating the complete file. Set
        dn->first to zero when the complete file was deallocated. Also
        update dn->length_of_chain to the new amount of clusters in the
        chain.
        * main.c (diskfs_hard_readonly): Remove global variable.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/fatfs/ChangeLog.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/fatfs/Makefile.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/fatfs/dir.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/fatfs/fat.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/fatfs/main.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: hurd/fatfs/ChangeLog
diff -u hurd/fatfs/ChangeLog:1.5 hurd/fatfs/ChangeLog:1.6
--- hurd/fatfs/ChangeLog:1.5    Tue Jul 29 10:33:01 2003
+++ hurd/fatfs/ChangeLog        Sat Aug  2 17:32:52 2003
@@ -1,3 +1,21 @@
+2003-08-01  Marco Gerards  <address@hidden>
+
+       * node-create.c: New file.
+       * Makefile (SRCS): Added node-created.c.
+       * dir.c: Include <hurd/fsys.h>.
+       (diskfs_direnter_hard): Initialize a new block with zeros. Enter
+       direntry and setup the virtual  inode. Also handle directories
+       correctly.
+       (diskfs_rewrite_hard): Function rewritten.
+       (diskfs_dirempty): Change logic to test if a file was deleted.
+       * fat.c (fat_extend_chain): Unlock spin_lock when returning from
+       function. Set dn->last to 0 when deallocating the complete
+       file. Update dn->last when not deallocating the complete file. Set
+       dn->first to zero when the complete file was deallocated. Also
+       update dn->length_of_chain to the new amount of clusters in the
+       chain.
+       * main.c (diskfs_hard_readonly): Remove global variable.
+
 2003-07-29  Jeff Bailey  <address@hidden>
 
        * fatfs.h (LOG2_BLOCKS_PER_CLUSTER): Fix typo.
Index: hurd/fatfs/Makefile
diff -u hurd/fatfs/Makefile:1.1 hurd/fatfs/Makefile:1.2
--- hurd/fatfs/Makefile:1.1     Tue Dec  3 15:52:59 2002
+++ hurd/fatfs/Makefile Sat Aug  2 17:32:52 2003
@@ -1,4 +1,4 @@
-#   Copyright (C) 1997 Free Software Foundation
+#   Copyright (C) 1997, 2003 Free Software Foundation
 #   Modified by Marcus Brinkmann, 2000-05-05
 #
 #   This program is free software; you can redistribute it and/or
@@ -19,7 +19,7 @@
 makemode := server
 
 target = fatfs
-SRCS = inode.c main.c dir.c pager.c fat.c virt-inode.c
+SRCS = inode.c main.c dir.c pager.c fat.c virt-inode.c node-create.c
 LCLHDRS = fat.h fatfs.h virt-inode.h
 DIST_FILES = EXTENSIONS
 
Index: hurd/fatfs/dir.c
diff -u hurd/fatfs/dir.c:1.2 hurd/fatfs/dir.c:1.3
--- hurd/fatfs/dir.c:1.2        Fri May  9 20:12:29 2003
+++ hurd/fatfs/dir.c    Sat Aug  2 17:32:52 2003
@@ -1,5 +1,5 @@
-/* main.c - FAT filesystem.
-   Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+/* dir.c - FAT filesystem.
+   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.
@@ -21,6 +21,8 @@
 #include <ctype.h>
 #include <string.h>
 #include <dirent.h>
+#include <hurd/fsys.h>
+
 #include "fatfs.h"
 
 /* The size of a directory block is usually just the cluster size.
@@ -617,8 +619,9 @@
               munmap ((caddr_t) ds->mapbuf, ds->mapextent);
               return err;
             }
-        }
-      
+         memset ((caddr_t) ds->mapbuf + oldsize, 0, bytes_per_cluster);
+       }
+
       new = (struct dirrect *) ((char *) ds->mapbuf + oldsize);
 
       dp->dn_stat.st_size = oldsize + bytes_per_cluster;
@@ -642,8 +645,27 @@
   memcpy (new->name, "           ", 11);
   memcpy (new->name, name, namelen % 11); /* XXX */
 
-  /* XXX We need to do much, much more here.  */
-  /* XXX What about creating . and .. for dirs?  */
+  write_word (new->first_cluster_low, np->dn->start_cluster & 0xffff);
+  write_word (new->first_cluster_high, np->dn->start_cluster >> 16);
+  write_dword (new->file_size, np->dn_stat.st_size);
+  
+  if (!(name[0] == '.' && (name[1] == '\0' 
+                          || (name[1] == '.'  && name[2] =='\0'))))
+    {
+      vi_key_t entry_key;
+      
+      entry_key.dir_inode = dp->cache_id;
+      entry_key.dir_offset = ((int) ds->entry) - ((int) ds->mapbuf);
+      
+      /* Set the key for this inode now because it wasn't know when
+        the inode was initialized.  */
+      vi_change (vi_lookup (np->cache_id), entry_key);
+      
+      if (np->dn_stat.st_mode & S_IFDIR)
+       new->attribute = FAT_DIR_ATTR_DIR;
+    }
+  else
+    new->attribute = FAT_DIR_ATTR_DIR;
 
   /* Mark the directory inode has having been written.  */
   dp->dn_set_mtime = 1;
@@ -692,19 +714,48 @@
 error_t
 diskfs_dirrewrite_hard (struct node *dp, struct node *np, struct dirstat *ds)
 {
+  error_t err;
+  vi_key_t entry_key;
+  mach_port_t control = MACH_PORT_NULL;
+  struct node *oldnp;
+  ino_t inode;
+  inode_t vinode;
+  
+  /*  We need the inode and vinode of the old node.  */
+  entry_key.dir_inode = dp->cache_id;
+  entry_key.dir_offset = ((int) ds->entry) - ((int) ds->mapbuf);
+  err = vi_rlookup (entry_key, &inode, &vinode, 0);
+  
+  assert (err != EINVAL);
+  
+  /*  Lookup the node, we already have a reference.  */
+  oldnp = ifind (inode);
+
   assert (ds->type == RENAME);
   assert (ds->stat == HERE_TIS);
 
   assert (!diskfs_readonly);
 
-  /* XXX We have to reimplement rename completely.  */
-  /*
-    ds->entry->inode = np->cache_id;
-  */
-  dp->dn_set_mtime = 1;
- 
+  /*  The link count must be 0 so the file will be removed and
+      the node will be dropped.  */
+  oldnp->dn_stat.st_nlink--;
+  assert (!oldnp->dn_stat.st_nlink);
+  
+  /* Close the file, free the referenced held by clients.  */
+  fshelp_fetch_control (&oldnp->transbox, &control);
+  
+  if (control)
+    {
+      fsys_goaway (control, FSYS_GOAWAY_UNLINK);
+      mach_port_deallocate (mach_task_self (), control);
+    }
+  
+  /*  Put the new key in the vinode.  */
+  vi_change (vi_lookup (np->cache_id), entry_key);
+   
   munmap ((caddr_t) ds->mapbuf, ds->mapextent);
 
+  dp->dn_set_mtime = 1;
   diskfs_file_update (dp, 1);
 
   return 0;
@@ -741,7 +792,7 @@
 
       if (entry->name[0] == FAT_DIR_NAME_LAST)
        break;
-      if (!entry->name[0] == FAT_DIR_NAME_DELETED
+      if ((char) entry->name[0] != FAT_DIR_NAME_DELETED
          && memcmp (entry->name, FAT_DIR_NAME_DOT, 11)
          && memcmp (entry->name, FAT_DIR_NAME_DOTDOT, 11))
        hit = 1;
Index: hurd/fatfs/fat.c
diff -u hurd/fatfs/fat.c:1.3 hurd/fatfs/fat.c:1.4
--- hurd/fatfs/fat.c:1.3        Tue Jul 29 10:58:44 2003
+++ hurd/fatfs/fat.c    Sat Aug  2 17:32:52 2003
@@ -385,14 +385,17 @@
        dn->last = dn->first = *table;
       return 0;
     }
-         
-  spin_lock(&dn->chain_extension_lock);
   
+  spin_lock(&dn->chain_extension_lock);
+
   /* If we already have what we need, or we have all clusters that are
      available without allocating new ones, go out.  */
   if (new_last_cluster < dn->length_of_chain
       || (!create && dn->chain_complete))
-    return 0;
+    {
+      spin_unlock(&dn->chain_extension_lock);
+      return 0;
+    }
 
   left = new_last_cluster + 1 - dn->length_of_chain;
 
@@ -517,6 +520,7 @@
       /* Deallocate the complete file.  */
       node->dn->start_cluster = 0;
       pos = count = offs = 0;
+      node->dn->last = 0;
     }
   else
     {
@@ -525,6 +529,11 @@
       while (count-- > 0)
        {
          assert (next);
+
+         /* This cluster is now the last cluster in the chain.  */
+         if (count == 0)
+           node->dn->last = next;
+
          next = next->next;
        }
       assert (next);
@@ -566,6 +575,11 @@
       free (next);
       next = next_next;
     }
+
+  if (clusters_to_keep == 0)
+    node->dn->first = 0;
+  
+  node->dn->length_of_chain = clusters_to_keep; 
 }
 
 
Index: hurd/fatfs/main.c
diff -u hurd/fatfs/main.c:1.2 hurd/fatfs/main.c:1.3
--- hurd/fatfs/main.c:1.2       Fri May  9 20:12:29 2003
+++ hurd/fatfs/main.c   Sat Aug  2 17:32:52 2003
@@ -43,7 +43,7 @@
 int diskfs_maxsymlinks = 8;     /* XXX */
 
 /* This filesystem is not capable of writing yet.  */
-int diskfs_readonly = 1, diskfs_hard_readonly = 1;
+int diskfs_readonly = 1;
 
 /* Handy source of zeroes.  */
 vm_address_t zerocluster;




reply via email to

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