bug-hurd
[Top][All Lists]
Advanced

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

Re: "" as target of symlink kills translator


From: Neal H Walfield
Subject: Re: "" as target of symlink kills translator
Date: Wed, 20 Jun 2001 23:15:38 -0500
User-agent: Mutt/1.3.18i

Here is a new patch.  A test run:

        neal@desdemona:~/foo (0)$ ls -l
        total 0
        -rw-r--r--    1 neal     neal            0 Jun 20 22:44 a
        -rw-r--r--    1 neal     neal            0 Jun 20 22:44 b
        -rw-r--r--    1 neal     neal            0 Jun 20 22:44 c
        lrwxr-xr-x    1 neal     neal            0 Jun 20 22:44 foo -> 
        neal@desdemona:~/foo (0)$ ls -l foo
        lrwxr-xr-x    1 neal     neal            0 Jun 20 22:44 foo -> 
        neal@desdemona:~/foo (0)$ ls -l foo/
        total 0
        -rw-r--r--    1 neal     neal            0 Jun 20 22:44 a
        -rw-r--r--    1 neal     neal            0 Jun 20 22:44 b
        -rw-r--r--    1 neal     neal            0 Jun 20 22:44 c
        lrwxr-xr-x    1 neal     neal            0 Jun 20 22:44 foo -> 
        neal@desdemona:~/foo (0)$ 

And the code:

Index: libdiskfs/dir-lookup.c
===================================================================
RCS file: /home/neal/cvs/hurd/libdiskfs/dir-lookup.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 dir-lookup.c
--- libdiskfs/dir-lookup.c      2001/06/16 22:41:55     1.1.1.2
+++ libdiskfs/dir-lookup.c      2001/06/21 04:12:55
@@ -333,19 +333,45 @@
          if (diskfs_read_symlink_hook)
            error = (*diskfs_read_symlink_hook)(np, pathbuf);
          if (!diskfs_read_symlink_hook || error == EINVAL)
-           error = diskfs_node_rdwr (np, pathbuf,
-                                     0, np->dn_stat.st_size, 0,
-                                     dircred, &amt);
+           {
+             error = diskfs_node_rdwr (np, pathbuf,
+                                       0, np->dn_stat.st_size, 0,
+                                       dircred, &amt);
+             assert (error || amt == np->dn_stat.st_size);
+           }
          if (error)
            goto out;
+
+         if (np->dn_stat.st_size == 0) /* i.e. symlink == "" */
+           {
+             newnamelen += 2;
+             if (pathbuflen < newnamelen)
+               {
+                 pathbuf = alloca (newnamelen);
+                 pathbuflen = newnamelen;
+               }
 
-         if (nextname)
+             pathbuf[0] = '.';
+             pathbuf[1] = '/';
+
+             if (nextname)
+               {
+                 bcopy (nextname, pathbuf + 2, nextnamelen - 1);
+                 pathbuf[nextnamelen + 1] = '\0';
+               }
+             else
+               pathbuf[2] = '\0';
+           }
+         else
            {
-             pathbuf[np->dn_stat.st_size] = '/';
-             bcopy (nextname, pathbuf + np->dn_stat.st_size + 1,
-                    nextnamelen - 1);
+             if (nextname)
+               {
+                 pathbuf[np->dn_stat.st_size] = '/';
+                 bcopy (nextname, pathbuf + np->dn_stat.st_size + 1,
+                        nextnamelen - 1);
+               }
+             pathbuf[nextnamelen + np->dn_stat.st_size] = '\0';
            }
-         pathbuf[nextnamelen + np->dn_stat.st_size] = '\0';
 
          if (pathbuf[0] == '/')
            {
@@ -389,6 +415,7 @@
      we just created this node.  */
 
  gotit:
+  assert (np);
   type = np->dn_stat.st_mode & S_IFMT;
 
   if (mustbedir && type != S_IFDIR)

Attachment: pgpPR7QvtEUEQ.pgp
Description: PGP signature


reply via email to

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