Changeset b5553a2 in mainline for uspace/srv/fs/tmpfs/tmpfs_ops.c
- Timestamp:
- 2008-02-16T11:23:19Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f17667a
- Parents:
- 8ccd2ea
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.