From ba5e2f04db2bf57788cf6e326f54bd858296c29e Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Mon, 6 Jun 2016 14:16:07 +1200 Subject: [PATCH] Add ability to hide lost_n_found directory Some people don't want it showing up in the directory structure. Signed-off-by: Charles Manning --- direct/test-framework/yaffs_nandsim_file.c | 2 +- yaffs_guts.c | 19 ++++++++++++++----- yaffs_guts.h | 2 ++ yaffs_verify.c | 14 ++++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/direct/test-framework/yaffs_nandsim_file.c b/direct/test-framework/yaffs_nandsim_file.c index 962b3d6..3beac5a 100644 --- a/direct/test-framework/yaffs_nandsim_file.c +++ b/direct/test-framework/yaffs_nandsim_file.c @@ -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; diff --git a/yaffs_guts.c b/yaffs_guts.c index bf58eca..c89b29c 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -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; diff --git a/yaffs_guts.h b/yaffs_guts.h index e2b2fb9..9cd554e 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -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. diff --git a/yaffs_verify.c b/yaffs_verify.c index e8f2f0a..4a2f5c3 100644 --- a/yaffs_verify.c +++ b/yaffs_verify.c @@ -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; -- 2.30.2