From ecdf58f5b4d4b5a24069a3f48a6a616116cdd88f Mon Sep 17 00:00:00 2001 From: adamdebek Date: Mon, 26 Aug 2024 14:50:39 +0200 Subject: [PATCH] add logs --- jffs2/dir.c | 7 ++++++- jffs2/fs.c | 1 + jffs2/gc.c | 4 +++- jffs2/jffs2_fs_i.h | 3 +++ jffs2/libjffs2.c | 5 +++++ jffs2/os-linux.h | 1 + jffs2/phoenix-rtos.h | 2 +- jffs2/write.c | 1 + 8 files changed, 21 insertions(+), 3 deletions(-) diff --git a/jffs2/dir.c b/jffs2/dir.c index f922bf6c..218e9625 100644 --- a/jffs2/dir.c +++ b/jffs2/dir.c @@ -12,6 +12,9 @@ #include "phoenix-rtos.h" +#include +#include +#include #include "jffs2_fs_i.h" #include "jffs2_fs_sb.h" #include "nodelist.h" @@ -136,12 +139,14 @@ static int jffs2_readdir(struct file *file, struct dir_context *ctx) jffs2_dbg(2, "Skipping deletion dirent \"%s\"\n", fd->name); ctx->pos++; + // printf("Del name: %s\n", fd->name); continue; } jffs2_dbg(2, "Dirent %ld: \"%s\", ino #%u, type %d\n", (unsigned long)ctx->pos, fd->name, fd->ino, fd->type); - if (!dir_emit(ctx, fd->name, strlen(fd->name), fd->ino, fd->type)) + if (!dir_emit(ctx, fd->name, strlen(fd->name), fd->ino, fd->type)) { break; + } ctx->pos++; } mutex_unlock(&f->sem); diff --git a/jffs2/fs.c b/jffs2/fs.c index 54c6823e..a7390eda 100644 --- a/jffs2/fs.c +++ b/jffs2/fs.c @@ -298,6 +298,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) inode->i_op = &jffs2_dir_inode_operations; inode->i_fop = &jffs2_dir_operations; + f->drefs++; break; } case S_IFREG: diff --git a/jffs2/gc.c b/jffs2/gc.c index 33ca5aa0..15de9db0 100644 --- a/jffs2/gc.c +++ b/jffs2/gc.c @@ -562,8 +562,9 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era } if (fd && fd->ino) { + // printf("gc: %s\n", fd->name); ret = jffs2_garbage_collect_dirent(c, jeb, f, fd); - } else if (fd) { + } else if (fd && !f->drefs) { ret = jffs2_garbage_collect_deletion_dirent(c, jeb, f, fd); } else { pr_warn("Raw node at 0x%08x wasn't in node lists for ino #%u\n", @@ -988,6 +989,7 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct /* No need for it any more. Just mark it obsolete and remove it from the list */ while (*fdp) { if ((*fdp) == fd) { + printf("del: %s\n", fd->name); found = 1; *fdp = fd->next; break; diff --git a/jffs2/jffs2_fs_i.h b/jffs2/jffs2_fs_i.h index 37f3b79f..b858d986 100644 --- a/jffs2/jffs2_fs_i.h +++ b/jffs2/jffs2_fs_i.h @@ -47,6 +47,9 @@ struct jffs2_inode_info { /* Some stuff we just have to keep in-core at all times, for each inode. */ struct jffs2_inode_cache *inocache; + /* Number of opened directory streams */ + uint16_t drefs; + uint16_t flags; uint8_t usercompr; struct inode vfs_inode; diff --git a/jffs2/libjffs2.c b/jffs2/libjffs2.c index d4c5eda9..3c91bbff 100644 --- a/jffs2/libjffs2.c +++ b/jffs2/libjffs2.c @@ -13,6 +13,7 @@ */ #include +#include #include #include @@ -820,6 +821,10 @@ static int libjffs2_close(void *info, oid_t *oid) return -EINVAL; struct inode *inode = ilookup(p->sb, oid->id); + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); + // mutex_lock(&f->sem); + f->drefs--; + // mutex_unlock(&f->sem); if (inode != NULL) { iput(inode); diff --git a/jffs2/os-linux.h b/jffs2/os-linux.h index c2fbec19..fd3d4ea4 100644 --- a/jffs2/os-linux.h +++ b/jffs2/os-linux.h @@ -56,6 +56,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) f->target = NULL; f->flags = 0; f->usercompr = 0; + f->drefs = 0; } diff --git a/jffs2/phoenix-rtos.h b/jffs2/phoenix-rtos.h index 71d3b026..1a9b14b5 100644 --- a/jffs2/phoenix-rtos.h +++ b/jffs2/phoenix-rtos.h @@ -350,7 +350,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) f->target = NULL; f->flags = 0; f->usercompr = 0; - + f->drefs = 0; } diff --git a/jffs2/write.c b/jffs2/write.c index fed2e30e..16f4c236 100644 --- a/jffs2/write.c +++ b/jffs2/write.c @@ -13,6 +13,7 @@ #include "phoenix-rtos.h" #include "nodelist.h" #include "compr.h" +#include int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,