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 962b3d6c69e12529cb660b603f1c821593a1586b..3beac5a03ad665f322e2af0cc55884860039fdc1 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 bf58eca1da0b3ceaf0316adbb7ed055b6519733b..c89b29ca86f7c92c8a56344698ef8e7515e35b82 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 e2b2fb9378afe615beba22b0eb86f3d65a992b99..9cd554e7577b726b2ff2ff9ee93b7509c7f0323e 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 e8f2f0a6c2be72ca23141975aab13991bfe1176a..4a2f5c3a0abc626ae7a78b120288a76e72b4f625 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;