xref: /nrf52832-nimble/rt-thread/components/dfs/filesystems/jffs2/porting.h (revision 104654410c56c573564690304ae786df310c91fc)
1 #ifndef _PORTING_H
2 #define _PORTING_H
3 
4 #include "jffs2_config.h"
5 /* the following should be same with os_sys_stat.h */
6 #define JFFS2_S_IFMT	 0x000003FF
7 #define JFFS2_S_IFDIR	 (1<<0)
8 #define JFFS2_S_IFREG	 (1<<3)
9 
10 struct jffs2_fs_info
11 {
12 	unsigned sector_size; /* a erasing block size*/
13 	unsigned nr_blocks; /* number of blocks in flash */
14 	unsigned free_size;
15 };
16 
17 struct jffs2_stat {
18     unsigned long   st_mode;     /* File mode */
19     unsigned int    st_ino;      /* File serial number */
20     unsigned int    st_dev;      /* ID of device containing file */
21     unsigned short  st_nlink;    /* Number of hard links */
22     unsigned short  st_uid;      /* User ID of the file owner */
23     unsigned short  st_gid;      /* Group ID of the file's group */
24     long  st_size;     /* File size (regular files only) */
25     long  st_atime;    /* Last access time */
26     long  st_mtime;    /* Last data modification time */
27     long  st_ctime;    /* Last file status change time */
28 };
29 
30 struct jffs2_dirent
31 {
32 #ifdef CYGPKG_FILEIO_DIRENT_DTYPE
33 
34 	unsigned long  d_type; // Only supported with FATFS, RAMFS, ROMFS,
35 	// and JFFS2.
36 	// d_type is not part of POSIX so
37 	// should be used with caution.
38 #endif
39 	char        d_name[JFFS2_NAME_MAX+1];
40 };
41 
42 extern cyg_fileops jffs2_fileops;
43 extern cyg_fileops jffs2_dirops;
44 extern struct cyg_fstab_entry jffs2_fste;
45 
46 time_t jffs2_get_timestamp(void);
47 void jffs2_get_info_from_sb(void * data, struct jffs2_fs_info * info);
48 int jffs2_porting_stat(cyg_mtab_entry * mte, cyg_dir dir, const char *name,
49 		      void * stat_buf);
50 
51 #endif
52