summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--isofs/ChangeLog30
-rw-r--r--isofs/inode.c34
-rw-r--r--isofs/isofs.h2
-rw-r--r--isofs/lookup.c12
-rw-r--r--isofs/rr.c6
5 files changed, 56 insertions, 28 deletions
diff --git a/isofs/ChangeLog b/isofs/ChangeLog
index 93411a23..69f5def6 100644
--- a/isofs/ChangeLog
+++ b/isofs/ChangeLog
@@ -1,3 +1,33 @@
+2000-11-26 Marcus Brinkmann <marcus@gnu.org>
+
+ Closes Debian Bug #68417:
+ * rr.c (rrip_work): In helper function add_comp set targused to
+ zero after malloc, and loop over realloc in case doubling is not
+ enough. After finalizing the link, set VALID_SL valid flag.
+ * inode.c (read_disknode): For links use rl->target instead
+ rl->name.
+
+ Closes Debian Bug #69281: Don't use file_start as inode numbers,
+ but the offset of the directory record in disk_image. This is what
+ Linux 2.4 does.
+ * isofs.h (struct disknode): New member struct dirrect *dr.
+ * inode.c: Fix comment about inode numbers.
+ (struct node_cache): Fix comment about file_start (it's not unique).
+ In fact, file_start is invalid for symlinks, and only stored here
+ for convenience. Maybe caching file_start can be avoided by
+ rearranging the code.
+ (inode_cache_find): Change first argument from off_t file_start
+ to struct dirrect *dr and fix the doc.
+ Compare cached value of DR with this argument, instead FILE_START.
+ (diskfs_cached_lookup): Set DR member of DN.
+ (load_inode): Call inode_cache_find with RECORD instead FILE_START.
+ Set DR member of DN.
+ (read_disknode): Set inode number to DR - DISK_IMAGE instead
+ FILE_START.
+ * lookup.c (diskfs_get_directs): Remove variable file_start.
+ Don't calculate file_start. Set D_FILENO to EP - DISK_IMAGE
+ instead FILE_START.
+
2000-07-26 Mark Kettenis <kettenis@gnu.org>
* Makefile (HURDLIBS): Reorder libs such that the threads lib
diff --git a/isofs/inode.c b/isofs/inode.c
index a364c19e..149031fa 100644
--- a/isofs/inode.c
+++ b/isofs/inode.c
@@ -23,9 +23,11 @@
#include "isofs.h"
-/* There is no such thing as an inode in this format, all such information
- being recorded in the directory entry. So we report inode numbers as
- absolute offsets from DISK_IMAGE. */
+/* There is no such thing as an inode in this format, all such
+ information being recorded in the directory entry. So we report
+ inode numbers as absolute offsets from DISK_IMAGE. But we can't use
+ the file start because of symlinks (and zero length files?), so we
+ use the directory record itself. */
#define INOHSZ 512
#if ((INOHSZ&(INOHSZ-1)) == 0)
@@ -38,7 +40,7 @@ struct node_cache
{
struct dirrect *dr; /* somewhere in disk_image */
- off_t file_start; /* UNIQUE start of file */
+ off_t file_start; /* start of file */
struct node *np; /* if live */
};
@@ -52,17 +54,17 @@ static error_t read_disknode (struct node *,
struct dirrect *, struct rrip_lookup *);
-/* See if node with file start FILE_START is in the cache. If so,
- return it, with one additional reference. diskfs_node_refcnt_lock must
- be held on entry to the call, and will be released iff the node
- was found in the cache. */
+/* See if node with directory entry RECORD is in the cache. If so,
+ return it, with one additional reference. diskfs_node_refcnt_lock
+ must be held on entry to the call, and will be released iff the
+ node was found in the cache. */
void
-inode_cache_find (off_t file_start, struct node **npp)
+inode_cache_find (struct dirrect *record, struct node **npp)
{
int i;
for (i = 0; i < node_cache_size; i++)
- if (node_cache[i].file_start == file_start
+ if (node_cache[i].dr == record
&& node_cache[i].np)
{
*npp = node_cache[i].np;
@@ -84,7 +86,7 @@ cache_inode (struct dirrect *dr, struct node *np)
/* First see if there's already an entry. */
for (i = 0; i < node_cache_size; i++)
- if (node_cache[i].file_start == np->dn->file_start)
+ if (node_cache[i].dr == np->dn->dr)
break;
if (i == node_cache_size)
@@ -148,6 +150,7 @@ diskfs_cached_lookup (int id, struct node **npp)
dn = malloc (sizeof (struct disknode));
dn->fileinfo = 0;
+ dn->dr = c->dr;
dn->file_start = c->file_start;
np = diskfs_make_node (dn);
np->cache_id = id + 1; /* see above for rationale for increment */
@@ -279,13 +282,14 @@ load_inode (struct node **npp, struct dirrect *record,
spin_lock (&diskfs_node_refcnt_lock);
/* First check the cache */
- inode_cache_find (file_start, npp);
+ inode_cache_find (record, npp);
if (*npp)
return 0;
/* Create a new node */
dn = malloc (sizeof (struct disknode));
dn->fileinfo = 0;
+ dn->dr = record;
dn->file_start = file_start;
np = diskfs_make_node (dn);
@@ -311,7 +315,7 @@ read_disknode (struct node *np, struct dirrect *dr,
struct stat *st = &np->dn_stat;
st->st_fstype = FSTYPE_ISO9660;
st->st_fsid = getpid ();
- st->st_ino = np->dn->file_start;
+ st->st_ino = (ino_t) ((void *) np->dn->dr - (void *) disk_image);
st->st_gen = 0;
st->st_rdev = 0;
@@ -410,8 +414,8 @@ read_disknode (struct node *np, struct dirrect *dr,
{
if (rl->valid & VALID_SL)
{
- np->dn->link_target = rl->name;
- rl->name = 0;
+ np->dn->link_target = rl->target;
+ rl->target = 0;
st->st_size = strlen (np->dn->link_target);
}
else
diff --git a/isofs/isofs.h b/isofs/isofs.h
index 23ec9d5f..68a94e93 100644
--- a/isofs/isofs.h
+++ b/isofs/isofs.h
@@ -33,6 +33,8 @@
struct disknode
{
+ struct dirrect *dr; /* Somewhere in disk_image. */
+
off_t file_start; /* In store->block_size units */
struct user_pager_info *fileinfo;
diff --git a/isofs/lookup.c b/isofs/lookup.c
index 6c259769..e6d2caf4 100644
--- a/isofs/lookup.c
+++ b/isofs/lookup.c
@@ -293,7 +293,6 @@ diskfs_get_directs (struct node *dp,
struct rrip_lookup rr;
const char *name;
size_t namlen, reclen;
- off_t file_start;
ep = (struct dirrect *) bufp;
@@ -354,16 +353,7 @@ diskfs_get_directs (struct node *dp,
/* Fill in entry */
- err = calculate_file_start (ep, &file_start, &rr);
- if (err)
- {
- diskfs_end_catch_exception ();
- if (ouralloc)
- munmap (*data, allocsize);
- return err;
- }
-
- userp->d_fileno = file_start;
+ userp->d_fileno = (ino_t) ((void *) ep - (void *) disk_image);
userp->d_type = DT_UNKNOWN;
userp->d_reclen = reclen;
userp->d_namlen = namlen;
diff --git a/isofs/rr.c b/isofs/rr.c
index 20fea897..b069a831 100644
--- a/isofs/rr.c
+++ b/isofs/rr.c
@@ -363,10 +363,10 @@ rrip_work (struct dirrect *dr, struct rrip_lookup *rr,
if (rr->target == 0)
{
rr->target = malloc (cnamelen * 2);
- targused = cnamelen;
+ targused = 0;
targalloced = cnamelen * 2;
}
- else if (targused + cnamelen > targalloced)
+ else while (targused + cnamelen > targalloced)
rr->target = realloc (rr->target, targalloced *= 2);
assert (rr->target);
@@ -435,6 +435,8 @@ rrip_work (struct dirrect *dr, struct rrip_lookup *rr,
else
add_comp ("", 1);
+ rr->valid |= VALID_SL;
+
free (slbuf);
goto next_field;
}