1 /* 2 * Copyright (C) 2015-2017 Alibaba Group Holding Limited 3 */ 4 5 #ifndef RAMFS_TYPES_H 6 #define RAMFS_TYPES_H 7 8 #include <stdint.h> 9 #include <unistd.h> 10 11 #define RAMFS_MAGIC 0x890910 12 #define RAMFS_LETTER 'U' 13 14 #define RAMFS_PATH_MAX 128 15 #define RAMFS_NAME_MAX RAMFS_PATH_MAX 16 #define RAMFS_LINK_MAX 1024 17 #define RAMFS_ALLOC_SIZE_MIN 1 18 19 /* Description of a link name */ 20 typedef struct link_name_s 21 { 22 char *name; 23 struct link_name_s *next; 24 } link_name_t; 25 26 /* Description of a file entry */ 27 typedef struct { 28 char *fn; 29 void *data; 30 uint32_t size; /* Data length in bytes */ 31 uint16_t refs; /* Open count */ 32 uint8_t const_data : 1; 33 uint8_t is_dir : 1; 34 uint8_t ar : 1; /* 1: Access for read is enabled */ 35 uint8_t aw : 1; /* 1: Access for write is enabled */ 36 37 link_name_t *link; 38 uint16_t link_count; 39 } ramfs_entry_t; 40 41 /* Description of a file */ 42 typedef struct { 43 ramfs_entry_t *entry; /* Pointer to the file entry */ 44 uint32_t rwp; /* Read write pointer */ 45 } ramfs_file_t; 46 47 /* Description of a directory */ 48 typedef struct { 49 char *dir_name; 50 ramfs_entry_t *last_entry; 51 } ramfs_dir_t; 52 53 typedef uint8_t ramfs_ll_node_t; 54 55 /* Description of a linked list */ 56 typedef struct { 57 uint32_t size; 58 ramfs_ll_node_t *head; 59 ramfs_ll_node_t *tail; 60 } ramfs_ll_t; 61 62 #endif /* RAMFS_TYPES_H */ 63 64