diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c index 289806cf2f5f..25dc12306d9e 100644 --- a/usr.sbin/makefs/cd9660.c +++ b/usr.sbin/makefs/cd9660.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660.c,v 1.8 2005/10/30 09:27:49 dyoung Exp $ */ +/* $NetBSD: cd9660.c,v 1.9 2005/10/31 08:29:19 dyoung Exp $ */ /* * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan @@ -101,7 +101,7 @@ #include #if defined(__RCSID) && !defined(__lint) -__RCSID("$NetBSD: cd9660.c,v 1.8 2005/10/30 09:27:49 dyoung Exp $"); +__RCSID("$NetBSD: cd9660.c,v 1.9 2005/10/31 08:29:19 dyoung Exp $"); #endif /* !__lint */ #include @@ -200,8 +200,6 @@ int cd9660_defaults_set = 0; static void cd9660_set_defaults(void) { - int i; - /*Fix the sector size for now, though the spec allows for other sizes*/ diskStructure.sectorSize = 2048; @@ -249,8 +247,6 @@ cd9660_set_defaults(void) diskStructure.is_bootable = 0; TAILQ_INIT(&diskStructure.boot_images); LIST_INIT(&diskStructure.boot_entries); - for (i = 0; i < CD9660_INODE_HASH_SIZE; i++) - SLIST_INIT(&diskStructure.inode_hash[i]); } void @@ -1780,42 +1776,6 @@ cd9660_populate_dot_records(cd9660node *node) cd9660_compute_record_size(node->dot_dot_record); } -static struct cd9660_inode * -cd9660_inode_lookup(iso9660_disk *disk, uint32_t ino) -{ - struct cd9660_inode *in; - struct cd9660_inode_head *head; - - head = &disk->inode_hash[CD9660_INODE_HASH(ino)]; - - SLIST_FOREACH(in, head, in_link) { - if (in->in_ino == ino) - break; - else if (in->in_ino > ino) - return NULL; - } - return in; -} - -static void -cd9660_inode_insert(iso9660_disk *disk, struct cd9660_inode *in) -{ - struct cd9660_inode *iter_in, *last_in = NULL; - struct cd9660_inode_head *head; - head = &disk->inode_hash[CD9660_INODE_HASH(in->in_ino)]; - - SLIST_FOREACH(iter_in, head, in_link) { - assert(iter_in->in_ino != in->in_ino); - if (iter_in->in_ino > in->in_ino) - break; - last_in = iter_in; - } - if (last_in == NULL) - SLIST_INSERT_HEAD(head, in, in_link); - else - SLIST_INSERT_AFTER(last_in, in, in_link); -} - /* * @param struct cd9660node *node The node * @param int The offset (in bytes) - SHOULD align to the beginning of a sector @@ -1833,7 +1793,7 @@ cd9660_compute_offsets(cd9660node *node, int startOffset) int used_bytes = 0; int current_sector_usage = 0; cd9660node *child; - struct cd9660_inode *in; + fsinode *inode; int r; assert(node != NULL); @@ -1914,25 +1874,20 @@ cd9660_compute_offsets(cd9660node *node, int startOffset) CD9660_BLOCKS(diskStructure.sectorSize, child->fileDataLength); - in = cd9660_inode_lookup(&diskStructure, - child->node->inode->st.st_ino); - if (in != NULL) { - INODE_WARNX(("%s: already allocated inode %d" - " (%" PRIu32 ") data sectors", __func__, - (int)child->node->inode->st.st_ino, - in->in_ino)); - } else if ((in = calloc(1, sizeof(*in))) == NULL) - err(EXIT_FAILURE, "%s: calloc", __func__); - else { - in->in_ino = child->node->inode->st.st_ino; - in->in_data_sector = + inode = child->node->inode; + if ((inode->flags & FI_ALLOCATED) == 0) { + inode->ino = CD9660_BLOCKS(diskStructure.sectorSize, used_bytes + startOffset); - cd9660_inode_insert(&diskStructure, in); + inode->flags |= FI_ALLOCATED; used_bytes += child->fileSectorsUsed * diskStructure.sectorSize; + } else { + INODE_WARNX(("%s: already allocated inode %d " + "data sectors at %" PRIu32, __func__, + (int)inode->st.st_ino, inode->ino)); } - child->fileDataSector = in->in_data_sector; + child->fileDataSector = inode->ino; cd9660_bothendian_dword(child->fileDataSector, child->isoDirRecord->extent); } diff --git a/usr.sbin/makefs/cd9660.h b/usr.sbin/makefs/cd9660.h index 1956d47f8750..b2b07972be63 100644 --- a/usr.sbin/makefs/cd9660.h +++ b/usr.sbin/makefs/cd9660.h @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660.h,v 1.8 2005/10/30 09:27:49 dyoung Exp $ */ +/* $NetBSD: cd9660.h,v 1.9 2005/10/31 08:29:19 dyoung Exp $ */ /* * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan @@ -169,7 +169,7 @@ typedef struct _cd9660node { /***** SIZE CALCULATION *****/ /*already stored in isoDirRecord, but this is an int version, and will be copied to isoDirRecord on writing*/ - int fileDataSector; + uint32_t fileDataSector; /* * same thing, though some notes: @@ -217,14 +217,6 @@ typedef struct _cd9660node { TAILQ_HEAD(susp_linked_list, ISO_SUSP_ATTRIBUTES) head; } cd9660node; -struct cd9660_inode { - uint32_t in_ino; - int in_data_sector; - SLIST_ENTRY(cd9660_inode) in_link; -}; - -#define CD9660_INODE_HASH(__inode) ((__inode) % CD9660_INODE_HASH_SIZE) - typedef struct _path_table_entry { u_char length[ISODCL (1, 1)]; @@ -250,9 +242,6 @@ typedef struct _iso9660_disk { cd9660node *rootNode; - SLIST_HEAD(cd9660_inode_head, - cd9660_inode) inode_hash[CD9660_INODE_HASH_SIZE]; - const char *rootFilesystemPath; /* Important sector numbers here */ diff --git a/usr.sbin/makefs/cd9660/cd9660_write.c b/usr.sbin/makefs/cd9660/cd9660_write.c index 9a778147c4f3..fe42ab73214c 100644 --- a/usr.sbin/makefs/cd9660/cd9660_write.c +++ b/usr.sbin/makefs/cd9660/cd9660_write.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_write.c,v 1.5 2005/10/30 09:27:49 dyoung Exp $ */ +/* $NetBSD: cd9660_write.c,v 1.6 2005/10/31 08:29:19 dyoung Exp $ */ /* * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(__lint) -__RCSID("$NetBSD: cd9660_write.c,v 1.5 2005/10/30 09:27:49 dyoung Exp $"); +__RCSID("$NetBSD: cd9660_write.c,v 1.6 2005/10/31 08:29:19 dyoung Exp $"); #endif /* !__lint */ static int cd9660_write_volume_descriptors(FILE *); @@ -283,8 +283,8 @@ cd9660_write_file(FILE *fd, cd9660node *writenode) INODE_WARNX(("%s: skipping written inode %d", __func__, (int)inode->st.st_ino)); } else if (writenode->fileDataLength > 0) { - INODE_WARNX(("%s: writing inode %d", __func__, - (int)inode->st.st_ino)); + INODE_WARNX(("%s: writing inode %d blocks at %" PRIu32, + __func__, (int)inode->st.st_ino, inode->ino)); inode->flags |= FI_WRITTEN; cd9660_compute_full_filename(writenode, temp_file_name, 0);