Changeset 2e7b6db in rtems
- Timestamp:
- 08/05/03 14:05:56 (21 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- db39db4
- Parents:
- da499ad
- Location:
- cpukit/libfs/src/dosfs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libfs/src/dosfs/msdos.h
rda499ad r2e7b6db 78 78 #define MSDOS_DIRECTORY RTEMS_FILESYSTEM_DIRECTORY 79 79 #define MSDOS_REGULAR_FILE RTEMS_FILESYSTEM_MEMORY_FILE 80 #define MSDOS_HARD_LINK RTEMS_FILESYSTEM_HARD_LINK /* pseudo type */ 80 81 81 82 typedef rtems_filesystem_node_types_t msdos_node_type_t; … … 302 303 303 304 int 305 msdos_file_link(rtems_filesystem_location_info_t *to_loc, 306 rtems_filesystem_location_info_t *pa_loc, 307 const char *token); 308 309 int 304 310 msdos_dir_open( 305 311 rtems_libio_t *iop, /* IN */ … … 342 348 msdos_node_type_t type, 343 349 char *name, 344 mode_t mode); 350 mode_t mode, 351 const fat_file_fd_t *link_fd); 345 352 346 353 /* Misc prototypes */ -
cpukit/libfs/src/dosfs/msdos_create.c
rda499ad r2e7b6db 41 41 * name - new node name 42 42 * mode - mode 43 * link_info - fs_info of existing node for a pseudo "hard-link" 44 * (see msdos_file.c, msdos_link for documentation) 43 45 * 44 46 * RETURNS: … … 51 53 msdos_node_type_t type, 52 54 char *name, 53 mode_t mode 55 mode_t mode, 56 const fat_file_fd_t *link_fd 54 57 ) 55 58 { … … 63 66 unsigned16 date = 0; 64 67 fat_auxiliary_t aux; 65 unsigned char new_node [MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE];68 unsigned char new_node [MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE]; 66 69 unsigned char dot_dotdot[MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE * 2]; 70 unsigned char link_node [MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE]; 71 unsigned32 sec = 0; 72 unsigned32 byte = 0; 67 73 68 74 memset(new_node, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE); … … 87 93 *MSDOS_DIR_FILE_SIZE(new_node) = MSDOS_INIT_DIR_SIZE; 88 94 89 if (type == MSDOS_DIRECTORY) 95 if (type == MSDOS_DIRECTORY){ 90 96 *MSDOS_DIR_ATTR(new_node) |= MSDOS_ATTR_DIRECTORY; 91 else 97 } 98 else if (type == MSDOS_HARD_LINK) { 99 /* 100 * when we establish a (temporary) hard link, 101 * we must copy some information from the original 102 * node to the newly created 103 */ 104 /* 105 * read the original directory entry 106 */ 107 sec = fat_cluster_num_to_sector_num(parent_loc->mt_entry, 108 link_fd->info_cln); 109 sec += (link_fd->info_ofs >> fs_info->fat.vol.sec_log2); 110 byte = (link_fd->info_ofs & (fs_info->fat.vol.bps - 1)); 111 112 ret = _fat_block_read(parent_loc->mt_entry, 113 sec, byte, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE, 114 link_node); 115 if (ret < 0) { 116 return -1; 117 } 118 /* 119 * copy various attributes 120 */ 121 *MSDOS_DIR_ATTR(new_node) =*MSDOS_DIR_ATTR(link_node); 122 *MSDOS_DIR_CRT_TIME_TENTH(new_node)=*MSDOS_DIR_CRT_TIME_TENTH(link_node); 123 *MSDOS_DIR_CRT_TIME(new_node) =*MSDOS_DIR_CRT_TIME(link_node); 124 *MSDOS_DIR_CRT_DATE(new_node) =*MSDOS_DIR_CRT_DATE(link_node); 125 126 /* 127 * copy/set "file size", "first cluster" 128 */ 129 *MSDOS_DIR_FILE_SIZE(new_node) =*MSDOS_DIR_FILE_SIZE(link_node); 130 131 *MSDOS_DIR_FIRST_CLUSTER_LOW(new_node) = 132 *MSDOS_DIR_FIRST_CLUSTER_LOW(link_node); 133 *MSDOS_DIR_FIRST_CLUSTER_HI(new_node) = 134 *MSDOS_DIR_FIRST_CLUSTER_HI(link_node); 135 /* 136 * set "archive bit" due to changes 137 */ 138 *MSDOS_DIR_ATTR(new_node) |= MSDOS_ATTR_ARCHIVE; 139 /* 140 * set "last access" date to today 141 */ 142 *MSDOS_DIR_LAST_ACCESS_DATE(new_node) = CT_LE_W(date); 143 } 144 else { /* regular file... */ 92 145 *MSDOS_DIR_ATTR(new_node) |= MSDOS_ATTR_ARCHIVE; 146 } 93 147 94 148 /* … … 205 259 return rc; 206 260 } 261 262 /* msdos_file_link -- 263 * Replacement for a file "link" operation. 264 * MSDOS FAT FS does not support links, but this call is needed to 265 * allow "rename" operations. The current NEWLIB rename performs a link 266 * from the old to the new name and then deletes the old filename. 267 * 268 * This pseudo-"link" operation will create a new directory entry, 269 * copy the file size and cluster information from the "old" 270 * to the "new" directory entry and then clear the file size and cluster 271 * info from the "old" filename, leaving this file as 272 * a valid, but empty entry. 273 * 274 * When this "link" call is part of a "rename" sequence, the "old" 275 * entry will be deleted in a subsequent "rmnod" call 276 * 277 * This function has been implemented by Thomas Doerfler, 278 * <Thomas.Doerfler@imd-systems.de> 279 * 280 * PARAMETERS: 281 * to_loc - node description for "existing" node 282 * par_loc - node description for "new" node 283 * token - name of new node 284 * 285 * RETURNS: 286 * RC_OK on success, or -1 if error occured (errno set appropriately) 287 */ 288 int 289 msdos_file_link(rtems_filesystem_location_info_t *to_loc, 290 rtems_filesystem_location_info_t *par_loc, 291 const char *token 292 ) 293 { 294 int rc = RC_OK; 295 rtems_status_code sc = RTEMS_SUCCESSFUL; 296 msdos_fs_info_t *fs_info = to_loc->mt_entry->fs_info; 297 fat_file_fd_t *to_fat_fd = to_loc->node_access; 298 fat_file_fd_t *par_fat_fd = par_loc->node_access; 299 char new_name[ MSDOS_NAME_MAX + 1 ]; 300 int len; 301 302 /* 303 * check spelling and format new node name 304 */ 305 if (MSDOS_NAME != msdos_get_token(token, new_name, &len)) { 306 set_errno_and_return_minus_one(ENAMETOOLONG); 307 } 308 /* 309 * verify, that the existing node can be linked to 310 * check that nodes are in same FS/volume? 311 */ 312 if (to_loc->mt_entry->fs_info != par_loc->mt_entry->fs_info) { 313 set_errno_and_return_minus_one(EXDEV); 314 } 315 /* 316 * lock volume 317 */ 318 sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT, 319 MSDOS_VOLUME_SEMAPHORE_TIMEOUT); 320 if (sc != RTEMS_SUCCESSFUL) 321 set_errno_and_return_minus_one(EIO); 322 323 324 /* 325 * create new directory entry as "hard link", 326 * copying relevant info from existing file 327 */ 328 rc = msdos_creat_node(par_loc,MSDOS_HARD_LINK,new_name,S_IFREG, 329 to_loc->node_access); 330 /* 331 * set file size and first cluster number of old entry to 0 332 */ 333 if (rc == RC_OK) { 334 to_fat_fd->fat_file_size = 0; 335 to_fat_fd->cln = FAT_EOF; 336 rc = msdos_set_first_cluster_num(to_loc->mt_entry, to_fat_fd); 337 if (rc == RC_OK) { 338 rc = msdos_set_file_size(par_loc->mt_entry, to_fat_fd); 339 } 340 } 341 /* 342 * FIXME: check error/abort handling 343 */ 344 rtems_semaphore_release(fs_info->vol_sema); 345 return rc; 346 } 347 -
cpukit/libfs/src/dosfs/msdos_init.c
rda499ad r2e7b6db 22 22 msdos_eval_path, 23 23 msdos_eval4make, 24 NULL, /* msdos_link */ 24 #if 0 25 NULL, /* msdos_link */ 26 #else 27 msdos_file_link, /* msdos_link (pseudo-functionality) */ 28 #endif 25 29 msdos_file_rmnod, 26 30 msdos_node_type, -
cpukit/libfs/src/dosfs/msdos_mknod.c
rda499ad r2e7b6db 84 84 85 85 /* Create an MSDOS node */ 86 rc = msdos_creat_node(pathloc, type, new_name, mode );86 rc = msdos_creat_node(pathloc, type, new_name, mode, NULL); 87 87 88 88 rtems_semaphore_release(fs_info->vol_sema);
Note: See TracChangeset
for help on using the changeset viewer.