Changeset b5553a2 in mainline
- Timestamp:
- 2008-02-16T11:23:19Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f17667a
- Parents:
- 8ccd2ea
- Location:
- uspace/srv
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/tmpfs/tmpfs_ops.c
r8ccd2ea rb5553a2 59 59 #define DENTRIES_BUCKETS 256 60 60 61 #define TMPFS_GET_INDEX(x) (((tmpfs_dentry_t *)(x))->index) 62 #define TMPFS_GET_LNKCNT(x) 1 63 61 64 /* 62 65 * Hash table of all directory entries. … … 128 131 /** Compare one component of path to a directory entry. 129 132 * 130 * @param dentry Directory entryto compare the path component with.133 * @param nodep Node to compare the path component with. 131 134 * @param component Array of characters holding component name. 132 135 * 133 136 * @return True on match, false otherwise. 134 137 */ 135 static bool match_component(tmpfs_dentry_t *dentry, const char *component) 136 { 138 static bool match_component(void *nodep, const char *component) 139 { 140 tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) nodep; 141 137 142 return !strcmp(dentry->name, component); 138 143 } 139 144 140 static unsigned long create_node(tmpfs_dentry_t *dentry,145 static void *create_node(void *nodep, 141 146 const char *component, int lflag) 142 147 { 148 tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) nodep; 149 143 150 assert(dentry->type == TMPFS_DIRECTORY); 144 151 assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY)); … … 146 153 tmpfs_dentry_t *node = malloc(sizeof(tmpfs_dentry_t)); 147 154 if (!node) 148 return 0;155 return NULL; 149 156 size_t len = strlen(component); 150 157 char *name = malloc(len + 1); 151 158 if (!name) { 152 159 free(node); 153 return 0;160 return NULL; 154 161 } 155 162 strcpy(name, component); … … 176 183 /* Insert the new node into the dentry hash table. */ 177 184 hash_table_insert(&dentries, &node->index, &node->dh_link); 178 return node->index;179 } 180 181 static int destroy_component( tmpfs_dentry_t *dentry)185 return (void *) node; 186 } 187 188 static int destroy_component(void *nodeptr) 182 189 { 183 190 return EPERM; … … 242 249 return; 243 250 } 244 unsigned long index= create_node(dcur,251 void *nodep = create_node(dcur, 245 252 component, lflag); 246 if ( index > 0) {247 ipc_answer_ 4(rid, EOK,253 if (nodep) { 254 ipc_answer_5(rid, EOK, 248 255 tmpfs_reg.fs_handle, dev_handle, 249 index, 0); 256 TMPFS_GET_INDEX(nodep), 0, 257 TMPFS_GET_LNKCNT(nodep)); 250 258 } else { 251 259 ipc_answer_0(rid, ENOSPC); … … 289 297 len = 0; 290 298 291 unsigned long index;292 i ndex = create_node(dcur, component, lflag);293 if (index) {294 ipc_answer_4(rid, EOK, tmpfs_reg.fs_handle,295 dev_handle, index, 0);299 void *nodep = create_node(dcur, component, lflag); 300 if (nodep) { 301 ipc_answer_5(rid, EOK, tmpfs_reg.fs_handle, 302 dev_handle, TMPFS_GET_INDEX(nodep), 0, 303 TMPFS_GET_LNKCNT(nodep)); 296 304 } else { 297 305 ipc_answer_0(rid, ENOSPC); … … 322 330 } 323 331 324 ipc_answer_ 4(rid, EOK, tmpfs_reg.fs_handle, dev_handle, dcur->index,325 dcur->size );332 ipc_answer_5(rid, EOK, tmpfs_reg.fs_handle, dev_handle, dcur->index, 333 dcur->size, TMPFS_GET_LNKCNT(dcur)); 326 334 } 327 335 -
uspace/srv/vfs/vfs.h
r8ccd2ea rb5553a2 174 174 vfs_triplet_t triplet; 175 175 size_t size; 176 unsigned lnkcnt; 176 177 } vfs_lookup_res_t; 177 178 … … 182 183 typedef struct { 183 184 VFS_TRIPLET; /**< Identity of the node. */ 184 unsigned refcnt; /**< Usage counter. */ 185 186 /** 187 * Usage counter. This includes, but is not limited to, all vfs_file_t 188 * structures that reference this node. 189 */ 190 unsigned refcnt; 191 192 /** Number of names this node has in the file system namespace. */ 193 unsigned lnkcnt; 194 185 195 link_t nh_link; /**< Node hash-table link. */ 186 196 size_t size; /**< Cached size of the file. */ -
uspace/srv/vfs/vfs_lookup.c
r8ccd2ea rb5553a2 169 169 result->triplet.index = (int) IPC_GET_ARG3(answer); 170 170 result->size = (size_t) IPC_GET_ARG4(answer); 171 result->lnkcnt = (unsigned) IPC_GET_ARG5(answer); 171 172 } 172 173 -
uspace/srv/vfs/vfs_node.c
r8ccd2ea rb5553a2 149 149 node->index = result->triplet.index; 150 150 node->size = result->size; 151 node->lnkcnt = result->lnkcnt; 151 152 link_initialize(&node->nh_link); 152 153 rwlock_initialize(&node->contents_rwlock); … … 157 158 158 159 assert(node->size == result->size); 160 assert(node->lnkcnt == result->lnkcnt); 159 161 160 162 _vfs_node_addref(node);
Note:
See TracChangeset
for help on using the changeset viewer.