Add ability to hide lost_n_found directory
authorCharles Manning <cdhmanning@gmail.com>
Mon, 6 Jun 2016 02:16:07 +0000 (14:16 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Mon, 6 Jun 2016 02:16:07 +0000 (14:16 +1200)
Some people don't want it showing up in the directory structure.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/test-framework/yaffs_nandsim_file.c
yaffs_guts.c
yaffs_guts.h
yaffs_verify.c

index 962b3d6..3beac5a 100644 (file)
@@ -54,7 +54,7 @@ struct yaffs_dev *yaffs_nandsim_install_drv(const char *dev_name,
        param->is_yaffs2 = 1;
        param->use_nand_ecc = 1;
        param->n_caches = 10;
-
+       /* param->hide_lost_n_found = 1; */
 
        if(yaffs_nand_install_drv(dev, chip) != YAFFS_OK)
                goto fail;
index bf58eca..c89b29c 100644 (file)
@@ -4635,8 +4635,11 @@ static int yaffs_check_dev_fns(struct yaffs_dev *dev)
 static int yaffs_create_initial_dir(struct yaffs_dev *dev)
 {
        /* Initialise the unlinked, deleted, root and lost+found directories */
-       dev->lost_n_found = dev->root_dir = NULL;
-       dev->unlinked_dir = dev->del_dir = NULL;
+       dev->lost_n_found = NULL;
+       dev->root_dir = NULL;
+       dev->unlinked_dir = NULL;
+       dev->del_dir = NULL;
+
        dev->unlinked_dir =
            yaffs_create_fake_dir(dev, YAFFS_OBJECTID_UNLINKED, S_IFDIR);
        dev->del_dir =
@@ -4648,9 +4651,15 @@ static int yaffs_create_initial_dir(struct yaffs_dev *dev)
            yaffs_create_fake_dir(dev, YAFFS_OBJECTID_LOSTNFOUND,
                                  YAFFS_LOSTNFOUND_MODE | S_IFDIR);
 
-       if (dev->lost_n_found && dev->root_dir && dev->unlinked_dir
-           && dev->del_dir) {
-               yaffs_add_obj_to_dir(dev->root_dir, dev->lost_n_found);
+       if (dev->lost_n_found &&
+               dev->root_dir &&
+               dev->unlinked_dir &&
+               dev->del_dir) {
+                       /* If lost-n-found is hidden then yank it out of the directory tree. */
+                       if (dev->param.hide_lost_n_found)
+                               list_del_init(&dev->lost_n_found->siblings);
+                       else
+                               yaffs_add_obj_to_dir(dev->root_dir, dev->lost_n_found);
                return YAFFS_OK;
        }
        return YAFFS_FAIL;
index e2b2fb9..9cd554e 100644 (file)
@@ -579,6 +579,8 @@ struct yaffs_param {
                                 * 0 = no limit.
                                */
 
+       int hide_lost_n_found;  /* Set non-zero to hide the lost-n-found dir. */
+
        /* The remove_obj_fn function must be supplied by OS flavours that
         * need it.
         * yaffs direct uses it to implement the faster readdir.
index e8f2f0a..4a2f5c3 100644 (file)
@@ -470,12 +470,26 @@ void yaffs_verify_dir(struct yaffs_obj *directory)
 {
        struct list_head *lh;
        struct yaffs_obj *list_obj;
+       struct yaffs_dev *dev;
 
        if (!directory) {
                BUG();
                return;
        }
 
+       dev = directory->my_dev;
+
+       if (!dev) {
+               BUG();
+               return;
+       }
+
+       if (directory == dev->root_dir ||
+           directory == dev->lost_n_found ||
+           directory == dev->unlinked_dir ||
+           directory == dev->del_dir)
+               return;
+
        if (yaffs_skip_full_verification(directory->my_dev))
                return;