From ce0f972cecd30fc1457aa0a9a0fa1ad966d23c12 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 26 Nov 2000 02:12:27 +0000 Subject: 2000-11-26 Marcus Brinkmann 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. --- isofs/inode.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'isofs/inode.c') 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 -- cgit v1.2.3