Hi,

While still very broken, this patch makes the creation of symlinks and
the reading of their links possible within tmpfs.

There were 3 problems:
1) (create_symlink_hook) the type of file wasn't being set, now set to DT_LNK.
2) (create_symlink hook) st_size never over 0 to begin with, now set
to be the length of TARGET's filename.
3) (diskfs_truncate) the special handling of symlinks wasn't being
allowed to happen due to the allocsize check.  The check doesn't make
sense for symlinks.  The check was moved to be after the symlink
truncation code.

To test this patch, I needed to pad struct tmpfs_dirent so that it
lines up with dirent.

Ben

--- node.c.orig 2005-07-24 09:56:39.000000000 -0400
+++ node.c      2005-07-24 09:55:46.000000000 -0400
@@ -330,6 +330,7 @@
 create_symlink_hook (struct node *np, const char *target)
 {
   assert (np->dn->u.lnk == 0);
+  np->dn_stat.st_size = strlen (target);
   if (np->dn_stat.st_size > 0)
     {
       const size_t size = np->dn_stat.st_size + 1;
@@ -337,6 +338,7 @@
       if (np->dn->u.lnk == 0)
        return ENOSPC;
       memcpy (np->dn->u.lnk, target, size);
+      np->dn->type = DT_LNK;
       adjust_used (size);
       recompute_blocks (np);
     }
@@ -380,8 +382,6 @@
 error_t
 diskfs_truncate (struct node *np, off_t size)
 {
-  if (np->allocsize <= size)
-    return 0;

   if (np->dn->type == DT_LNK)
     {
@@ -392,6 +392,9 @@
       return 0;
     }

+  if (np->allocsize <= size)
+    return 0;
+
   assert (np->dn->type == DT_REG);

   if (default_pager == MACH_PORT_NULL)


_______________________________________________
Bug-hurd mailing list
Bug-hurd@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-hurd

Reply via email to