Skip to content

Android’s yaffs2 filesystem

February 17, 2011

I intend to update this post with much more detail, but for now I wanted to note a few things about yaffs2.

The yaffs2 filesystem front-end which hooks up to the VFS is implemented in fs/yaffs2/yaffs_fs.c. There are many version dependent compilation routes as usual. With so much information I decided to focus on an area I know was regularly executed – readdir.

fs/yaffs2/yaffs_fs.c
static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir);

…and here are the relevant structures.

include/linux/fs.h

struct file {
	/*
	 * fu_list becomes invalid after file_free is called and queued via
	 * fu_rcuhead for RCU freeing
	 */
	union {
		struct list_head	fu_list;
		struct rcu_head 	fu_rcuhead;
	} f_u;
	struct path		f_path;
#define f_dentry	f_path.dentry
#define f_vfsmnt	f_path.mnt
	const struct file_operations	*f_op;
	atomic_long_t		f_count;
	unsigned int 		f_flags;
	fmode_t			f_mode;
	loff_t			f_pos;
	struct fown_struct	f_owner;
	const struct cred	*f_cred;
	struct file_ra_state	f_ra;

	u64			f_version;
#ifdef CONFIG_SECURITY
	void			*f_security;
#endif
	/* needed for tty driver, and maybe others */
	void			*private_data;

#ifdef CONFIG_EPOLL
	/* Used by fs/eventpoll.c to link all the hooks to this file */
	struct list_head	f_ep_links;
	spinlock_t		f_ep_lock;
#endif /* #ifdef CONFIG_EPOLL */
	struct address_space	*f_mapping;
#ifdef CONFIG_DEBUG_WRITECOUNT
	unsigned long f_mnt_write_state;
#endif
};

include/linux/dirent.h

struct linux_dirent64 {
	u64		d_ino;
	s64		d_off;
	unsigned short	d_reclen;
	unsigned char	d_type;
	char		d_name[0];
};

From → Android, Linux, Technology

Leave a Comment

Leave a comment