]> Zhao Yanbai Git Server - minix.git/commitdiff
isofs: basic improvements 57/2757/4
authorDavid van Moolenbroek <david@minix3.org>
Sun, 24 Aug 2014 11:50:23 +0000 (11:50 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Thu, 18 Sep 2014 13:00:52 +0000 (13:00 +0000)
- fix for "out of extents" panic;
- return ENOENT when a file name does not exist;
- inode count sanity check upon unmount.

Change-Id: Icb97dbaf7c8aec463438f06b341defca357094b2

minix/fs/iso9660fs/inode.c
minix/fs/iso9660fs/mount.c
minix/fs/iso9660fs/path.c
minix/fs/iso9660fs/proto.h

index 4b12c660c6e08de061f9d533c72e453b3432d01d..1bcaf5f1e8ea478d5a00bb33c1cd73abd10d8f76 100644 (file)
@@ -212,6 +212,7 @@ void read_inode_iso9660(struct inode *i,
 
        /* Parse first extent. */
        if (dir_rec->data_length_l > 0) {
+               assert(i->extent == NULL);
                i->extent = alloc_extent();
                i->extent->location = dir_rec->loc_extent_l +
                                      dir_rec->ext_attr_rec_length;
@@ -299,6 +300,7 @@ void read_inode_extents(struct inode *i,
                    (memcmp(dir_rec->file_id, extent_rec->file_id,
                    dir_rec->length_file_id) == 0)) {
                        /* Add the extent at the end of the linked list. */
+                       assert(cur_extent->next == NULL);
                        cur_extent->next = alloc_extent();
                        cur_extent->next->location = dir_rec->loc_extent_l +
                            dir_rec->ext_attr_rec_length;
@@ -388,3 +390,15 @@ int check_dir_record(const struct iso9660_dir_record *d, size_t offset)
 
        return OK;
 }
+
+int check_inodes(void)
+{
+       /* Check whether there are no more inodes in use. Called on unmount. */
+       int i;
+
+       for (i = 0; i < NR_INODE_RECORDS; i++)
+               if (inodes[i].i_count > 0)
+                       return FALSE;
+
+       return TRUE;
+}
index 9cbe06a70c77f32cc6e624f61921bb0ed14ee5e7..5b9266f9b3eed0648db416d94085b3f02a680d48 100644 (file)
@@ -60,4 +60,7 @@ void fs_unmount(void)
        release_vol_pri_desc(&v_pri);   /* Release the super block */
 
        bdev_close(fs_dev);
+
+       if (check_inodes() == FALSE)
+               printf("ISOFS: unmounting with in-use inodes!\n");
 }
index df800fd211ad8615adf349ee3aa79a0f893d650c..04af43cdf8eaf668b1a7a72bb093c3654bde6ae1 100644 (file)
@@ -41,12 +41,16 @@ static int search_dir(
                        r = read_inode(dir_tmp, ldir_ptr->extent, pos, &pos);
                        if ((r != OK) || (pos >= ldir_ptr->i_stat.st_size)) {
                                put_inode(dir_tmp);
-                               return EINVAL;
+                               return ENOENT;
                        }
+                       /* Temporary fix for extent spilling */
+                       put_inode(dir_tmp);
+                       dir_tmp = alloc_inode();
+                       /* End of fix */
                        r = read_inode(dir_tmp, ldir_ptr->extent, pos, &pos);
                        if ((r != OK) || (pos >= ldir_ptr->i_stat.st_size)) {
                                put_inode(dir_tmp);
-                               return EINVAL;
+                               return ENOENT;
                        }
                        *numb = dir_tmp->i_stat.st_ino;
                        put_inode(dir_tmp);
@@ -60,7 +64,7 @@ static int search_dir(
                r = read_inode(dir_tmp, ldir_ptr->extent, pos, &pos);
                if ((r != OK) || (pos >= ldir_ptr->i_stat.st_size)) {
                        put_inode(dir_tmp);
-                       return EINVAL;
+                       return ENOENT;
                }
 
                if ((strcmp(dir_tmp->i_name, string) == 0) ||
index 106c764906cb91e9b8498c403eeace7f774e0bb5..051eb052f3ff0d99356a2082eb14dd68d682016f 100644 (file)
@@ -28,6 +28,8 @@ void read_inode_susp(struct inode *i, const struct iso9660_dir_record *dir_rec,
 
 int check_dir_record(const struct iso9660_dir_record *d, size_t offset);
 
+int check_inodes(void);
+
 /* link.c */
 ssize_t fs_rdlink(ino_t ino_nr, struct fsdriver_data *data, size_t bytes);