Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdebek committed Aug 29, 2024
1 parent ac000e1 commit ecdf58f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 3 deletions.
7 changes: 6 additions & 1 deletion jffs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@


#include "phoenix-rtos.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include "jffs2_fs_i.h"
#include "jffs2_fs_sb.h"
#include "nodelist.h"
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions jffs2/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion jffs2/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions jffs2/jffs2_fs_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions jffs2/libjffs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#include <poll.h>
#include <stdio.h>
#include <sys/statvfs.h>
#include <phoenix/attribute.h>

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions jffs2/os-linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
2 changes: 1 addition & 1 deletion jffs2/phoenix-rtos.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
1 change: 1 addition & 0 deletions jffs2/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "phoenix-rtos.h"
#include "nodelist.h"
#include "compr.h"
#include <stdio.h>


int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
Expand Down

0 comments on commit ecdf58f

Please sign in to comment.