diff options
author | Ralf Corsepius <ralf.corsepius@rtems.org> | 2009-11-29 13:20:53 +0000 |
---|---|---|
committer | Ralf Corsepius <ralf.corsepius@rtems.org> | 2009-11-29 13:20:53 +0000 |
commit | 0a7278e49713596cd0d4b7e2d071e40a6940746f (patch) | |
tree | c1c61b6d608ae574575294eb70bdd15a12362d6a /cpukit/libfs/src/dosfs | |
parent | Whitespace removal. (diff) | |
download | rtems-0a7278e49713596cd0d4b7e2d071e40a6940746f.tar.bz2 |
Whitespace removal.
Diffstat (limited to 'cpukit/libfs/src/dosfs')
-rw-r--r-- | cpukit/libfs/src/dosfs/dosfs.h | 4 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/fat.c | 32 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/fat.h | 20 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/fat_file.c | 4 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_conv.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_create.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_dir.c | 22 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_format.c | 154 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_misc.c | 76 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_mknod.c | 2 |
10 files changed, 159 insertions, 159 deletions
diff --git a/cpukit/libfs/src/dosfs/dosfs.h b/cpukit/libfs/src/dosfs/dosfs.h index cde67e38e3..eb99411993 100644 --- a/cpukit/libfs/src/dosfs/dosfs.h +++ b/cpukit/libfs/src/dosfs/dosfs.h @@ -3,7 +3,7 @@ * * Application interface to MSDOS filesystem. */ - + /* * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia * Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru> @@ -14,7 +14,7 @@ * * @(#) $Id$ */ - + #ifndef _RTEMS_DOSFS_H #define _RTEMS_DOSFS_H diff --git a/cpukit/libfs/src/dosfs/fat.c b/cpukit/libfs/src/dosfs/fat.c index 0c30053a72..123e86b324 100644 --- a/cpukit/libfs/src/dosfs/fat.c +++ b/cpukit/libfs/src/dosfs/fat.c @@ -281,7 +281,7 @@ _fat_block_release( fat_fs_info_t *fs_info = mt_entry->fs_info; return fat_buf_release(fs_info); } - + /* fat_cluster_read -- * wrapper for reading a whole cluster at once * @@ -398,9 +398,9 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry) /* Evaluate boot record */ vol->bps = FAT_GET_BR_BYTES_PER_SECTOR(boot_rec); - - if ( (vol->bps != 512) && - (vol->bps != 1024) && + + if ( (vol->bps != 512) && + (vol->bps != 1024) && (vol->bps != 2048) && (vol->bps != 4096)) { @@ -443,7 +443,7 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry) vol->fat_loc = FAT_GET_BR_RESERVED_SECTORS_NUM(boot_rec); vol->rdir_entrs = FAT_GET_BR_FILES_PER_ROOT_DIR(boot_rec); - + /* calculate the count of sectors occupied by the root directory */ vol->rdir_secs = ((vol->rdir_entrs * FAT_DIRENTRY_SIZE) + (vol->bps - 1)) / vol->bps; @@ -454,18 +454,18 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry) vol->fat_length = FAT_GET_BR_SECTORS_PER_FAT(boot_rec); else vol->fat_length = FAT_GET_BR_SECTORS_PER_FAT32(boot_rec); - - vol->data_fsec = vol->fat_loc + vol->fats * vol->fat_length + + + vol->data_fsec = vol->fat_loc + vol->fats * vol->fat_length + vol->rdir_secs; /* for FAT12/16 root dir starts at(sector) */ vol->rdir_loc = vol->fat_loc + vol->fats * vol->fat_length; - + if ( (FAT_GET_BR_TOTAL_SECTORS_NUM16(boot_rec)) != 0) vol->tot_secs = FAT_GET_BR_TOTAL_SECTORS_NUM16(boot_rec); else vol->tot_secs = FAT_GET_BR_TOTAL_SECTORS_NUM32(boot_rec); - + data_secs = vol->tot_secs - vol->data_fsec; vol->data_cls = data_secs / vol->spc; @@ -496,7 +496,7 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry) if (vol->type == FAT_FAT32) { vol->rdir_cl = FAT_GET_BR_FAT32_ROOT_CLUSTER(boot_rec); - + vol->mirror = FAT_GET_BR_EXT_FLAGS(boot_rec) & FAT_BR_EXT_FLAGS_MIRROR; if (vol->mirror) vol->afat = FAT_GET_BR_EXT_FLAGS(boot_rec) & FAT_BR_EXT_FLAGS_FAT_NUM; @@ -517,9 +517,9 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry) { rtems_disk_release(vol->dd); return -1; - } - - if (FAT_GET_FSINFO_LEAD_SIGNATURE(fs_info_sector) != + } + + if (FAT_GET_FSINFO_LEAD_SIGNATURE(fs_info_sector) != FAT_FSINFO_LEAD_SIGNATURE_VALUE) { _fat_block_release(mt_entry); @@ -535,11 +535,11 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry) _fat_block_release(mt_entry); rtems_disk_release(vol->dd); return -1; - } - + } + vol->free_cls = FAT_GET_FSINFO_FREE_CLUSTER_COUNT(fs_info_sector); vol->next_cl = FAT_GET_FSINFO_NEXT_FREE_CLUSTER(fs_info_sector); - rc = fat_fat32_update_fsinfo_sector(mt_entry, 0xFFFFFFFF, + rc = fat_fat32_update_fsinfo_sector(mt_entry, 0xFFFFFFFF, 0xFFFFFFFF); if ( rc != RC_OK ) { diff --git a/cpukit/libfs/src/dosfs/fat.h b/cpukit/libfs/src/dosfs/fat.h index 61eb8c758c..8d62662c10 100644 --- a/cpukit/libfs/src/dosfs/fat.h +++ b/cpukit/libfs/src/dosfs/fat.h @@ -50,7 +50,7 @@ extern "C" { # define CF_LE_L(v) CPU_swap_u32((uint32_t)(v)) # define CT_LE_W(v) CPU_swap_u16((uint16_t)(v)) # define CT_LE_L(v) CPU_swap_u32((uint32_t)(v)) -#else +#else # define CF_LE_W(v) (v) # define CF_LE_L(v) (v) # define CT_LE_W(v) (v) @@ -103,7 +103,7 @@ extern "C" { #define FAT_GET_ADDR(x, ofs) ((uint8_t *)(x) + (ofs)) -#define FAT_GET_VAL8(x, ofs) (uint8_t)(*((uint8_t *)(x) + (ofs))) +#define FAT_GET_VAL8(x, ofs) (uint8_t)(*((uint8_t *)(x) + (ofs))) #define FAT_GET_VAL16(x, ofs) \ (uint16_t)( (*((uint8_t *)(x) + (ofs))) | \ @@ -114,10 +114,10 @@ extern "C" { ((uint32_t)(*((uint8_t *)(x) + (ofs) + 1)) << 8) | \ ((uint32_t)(*((uint8_t *)(x) + (ofs) + 2)) << 16) | \ ((uint32_t)(*((uint8_t *)(x) + (ofs) + 3)) << 24) ) - + #define FAT_SET_VAL8(x, ofs,val) \ (*((uint8_t *)(x)+(ofs))=(uint8_t)(val)) - + #define FAT_SET_VAL16(x, ofs,val) do { \ FAT_SET_VAL8((x),(ofs),(val)); \ FAT_SET_VAL8((x),(ofs)+1,(val)>>8);\ @@ -139,8 +139,8 @@ extern "C" { #define FAT_GET_BR_BYTES_PER_SECTOR(x) FAT_GET_VAL16(x, 11) #define FAT_SET_BR_BYTES_PER_SECTOR(x,val) FAT_SET_VAL16(x, 11,val) -#define FAT_GET_BR_SECTORS_PER_CLUSTER(x) FAT_GET_VAL8( x, 13) -#define FAT_SET_BR_SECTORS_PER_CLUSTER(x,val)FAT_SET_VAL8( x, 13,val) +#define FAT_GET_BR_SECTORS_PER_CLUSTER(x) FAT_GET_VAL8( x, 13) +#define FAT_SET_BR_SECTORS_PER_CLUSTER(x,val)FAT_SET_VAL8( x, 13,val) #define FAT_GET_BR_RESERVED_SECTORS_NUM(x) FAT_GET_VAL16(x, 14) #define FAT_SET_BR_RESERVED_SECTORS_NUM(x,val) FAT_SET_VAL16(x, 14,val) @@ -154,8 +154,8 @@ extern "C" { #define FAT_GET_BR_TOTAL_SECTORS_NUM16(x) FAT_GET_VAL16(x, 19) #define FAT_SET_BR_TOTAL_SECTORS_NUM16(x,val)FAT_SET_VAL16(x, 19,val) -#define FAT_GET_BR_MEDIA(x) FAT_GET_VAL8( x, 21) -#define FAT_SET_BR_MEDIA(x,val) FAT_SET_VAL8( x, 21,val) +#define FAT_GET_BR_MEDIA(x) FAT_GET_VAL8( x, 21) +#define FAT_SET_BR_MEDIA(x,val) FAT_SET_VAL8( x, 21,val) #define FAT_GET_BR_SECTORS_PER_FAT(x) FAT_GET_VAL16(x, 22) #define FAT_SET_BR_SECTORS_PER_FAT(x,val) FAT_SET_VAL16(x, 22,val) @@ -251,8 +251,8 @@ extern "C" { #define FAT_GET_FSINFO_TRAIL_SIGNATURE(x) FAT_GET_VAL32(x,508) #define FAT_SET_FSINFO_TRAIL_SIGNATURE(x,val) FAT_SET_VAL32(x,508,val) #define FAT_FSINFO_TRAIL_SIGNATURE_VALUE (0xAA550000) -/* - * I read FSInfo sector from offset 484 to access the information, so offsets +/* + * I read FSInfo sector from offset 484 to access the information, so offsets * of these fields a relative */ #define FAT_GET_FSINFO_FREE_CLUSTER_COUNT(x) FAT_GET_VAL32(x, 4) diff --git a/cpukit/libfs/src/dosfs/fat_file.c b/cpukit/libfs/src/dosfs/fat_file.c index b1a642f54b..0cd5f286db 100644 --- a/cpukit/libfs/src/dosfs/fat_file.c +++ b/cpukit/libfs/src/dosfs/fat_file.c @@ -115,7 +115,7 @@ fat_file_open( rtems_set_errno_and_return_minus_one( ENOMEM ); memset(lfat_fd, 0, sizeof(fat_file_fd_t)); - + lfat_fd->links_num = 1; lfat_fd->flags &= ~FAT_FILE_REMOVED; lfat_fd->map.last_cln = FAT_UNDEFINED_VALUE; @@ -584,7 +584,7 @@ fat_file_extend( } fat_fd->fat_file_size = new_length; - + return RC_OK; } diff --git a/cpukit/libfs/src/dosfs/msdos_conv.c b/cpukit/libfs/src/dosfs/msdos_conv.c index dadc73488c..ce1cf14706 100644 --- a/cpukit/libfs/src/dosfs/msdos_conv.c +++ b/cpukit/libfs/src/dosfs/msdos_conv.c @@ -274,7 +274,7 @@ msdos_filename_unix2dos(const char *un, int unlen, char *dn) un++; unlen--; } - + /* * Copy the unix filename into the dos filename string upto the end * of string, a '.', or 8 characters. Whichever happens first stops diff --git a/cpukit/libfs/src/dosfs/msdos_create.c b/cpukit/libfs/src/dosfs/msdos_create.c index f7bd97196c..a9d8dbaac3 100644 --- a/cpukit/libfs/src/dosfs/msdos_create.c +++ b/cpukit/libfs/src/dosfs/msdos_create.c @@ -80,7 +80,7 @@ msdos_creat_node(rtems_filesystem_location_info_t *parent_loc, uint32_t byte = 0; fat_dir_pos_init(&dir_pos); - + memset(short_node, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE); memset(dot_dotdot, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE * 2); diff --git a/cpukit/libfs/src/dosfs/msdos_dir.c b/cpukit/libfs/src/dosfs/msdos_dir.c index 43ff65291b..6fa3ddecf1 100644 --- a/cpukit/libfs/src/dosfs/msdos_dir.c +++ b/cpukit/libfs/src/dosfs/msdos_dir.c @@ -14,7 +14,7 @@ #include "config.h" #endif -#include <ctype.h> +#include <ctype.h> #include <stdlib.h> #include <unistd.h> #include <assert.h> @@ -258,7 +258,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) for (i = 0; i < ret; i += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE) { char* entry = (char*) fs_info->cl_buf + i; - + /* * Is this directory from here on empty ? */ @@ -288,7 +288,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) int o; char* p; int q; - + /* * Is this is the first entry of a LFN ? */ @@ -306,7 +306,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) */ lfn_start = ((j * bts2rd) + i) / MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE; - + /* * Get the number of entries so we can count down and * also the checksum of the short entry. @@ -330,7 +330,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) lfn_start = FAT_FILE_SHORT_NAME; continue; } - + /* * Extract the file name into the directory entry. The data is * stored in UNICODE characters (16bit). No translation is @@ -340,16 +340,16 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) * trailing nul character. We need to range check the length to * fit in the directory entry name field. */ - + lfn_entries--; p = entry + 1; o = lfn_entries * MSDOS_LFN_LEN_PER_ENTRY; - + for (q = 0; q < MSDOS_LFN_LEN_PER_ENTRY; q++) { if (o >= (sizeof(tmp_dirent.d_name) - 1)) break; - + tmp_dirent.d_name[o++] = *p; if (*p == '\0') @@ -372,7 +372,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) else { fat_dir_pos_t dir_pos; - + /* * Skip active entries until get the entry to start from. */ @@ -446,7 +446,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) { tmp_dirent.d_namlen = strlen(tmp_dirent.d_name); } - + memcpy(buffer + cmpltd, &tmp_dirent, sizeof(struct dirent)); iop->offset = iop->offset + sizeof(struct dirent); @@ -461,7 +461,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) return rc; } } - + if (count <= 0) break; } diff --git a/cpukit/libfs/src/dosfs/msdos_format.c b/cpukit/libfs/src/dosfs/msdos_format.c index 23beb4d144..98cb334787 100644 --- a/cpukit/libfs/src/dosfs/msdos_format.c +++ b/cpukit/libfs/src/dosfs/msdos_format.c @@ -180,7 +180,7 @@ static int msdos_format_fill_sectors char *fill_buffer = NULL; uint32_t total_sectors = sector_cnt; int last_percent = -1; - + /* * allocate and fill buffer */ @@ -200,7 +200,7 @@ static int msdos_format_fill_sectors /* * write to consecutive sectors */ - while ((ret_val == 0) && + while ((ret_val == 0) && (sector_cnt > 0)) { int percent = (sector_cnt * 100) / total_sectors; if (percent != last_percent) { @@ -212,13 +212,13 @@ static int msdos_format_fill_sectors start_sector++; sector_cnt--; } - + msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL, "\n"); if (ret_val) msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_INFO, "filling error on sector: %d\n", start_sector); - + /* * cleanup */ @@ -301,7 +301,7 @@ static int msdos_format_eval_sectors_per_cluster while (MS_BYTES_PER_CLUSTER_LIMIT / bytes_per_sector < sectors_per_cluster) { sectors_per_cluster /= 2; } - + do { /* * compute number of data clusters for current data: @@ -320,7 +320,7 @@ static int msdos_format_eval_sectors_per_cluster fat_capacity = fatdata_cluster_cnt * 4; } - sectors_per_fat = ((fat_capacity + sectors_per_fat = ((fat_capacity + (bytes_per_sector - 1)) / bytes_per_sector); @@ -341,7 +341,7 @@ static int msdos_format_eval_sectors_per_cluster /* * when maximum cluster size is exceeded, we have invalid data, abort... */ - if ((sectors_per_cluster * bytes_per_sector) + if ((sectors_per_cluster * bytes_per_sector) > MS_BYTES_PER_CLUSTER_LIMIT) { ret_val = EINVAL; finished = true; @@ -384,9 +384,9 @@ static int msdos_format_determine_fmt_params uint32_t onebit; uint32_t sectors_per_cluster_adj = 0; uint64_t total_size = 0; - + memset(fmt_params,0,sizeof(*fmt_params)); - /* + /* * this one is fixed in this implementation. * At least one thing we don't have to magically guess... */ @@ -402,7 +402,7 @@ static int msdos_format_determine_fmt_params * determine number of FATs */ if (ret_val == 0) { - if ((rqdata == NULL) || + if ((rqdata == NULL) || (rqdata->fat_num == 0)) { fmt_params->fat_num = 2; } @@ -413,33 +413,33 @@ static int msdos_format_determine_fmt_params ret_val = EINVAL; } } - + if (ret_val == 0) msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL, "number of fats: %d\n", fmt_params->fat_num); - + /* * Now we get sort of a loop when determining things: - * The FAT type (FAT12/16/32) is determined ONLY from the + * The FAT type (FAT12/16/32) is determined ONLY from the * data cluster count: * Disks with data cluster count < 4085 are FAT12. * Disks with data cluster count < 65525 are FAT16. - * The rest is FAT32 (no FAT128 available yet :-) + * The rest is FAT32 (no FAT128 available yet :-) * - * The number of data clusters is the - * total capacity + * The number of data clusters is the + * total capacity * minus reserved sectors * minus root directory ares * minus storage needed for the FAT (and its copy/copies). - * + * * The last item once again depends on the FAT type and the cluster count. - * + * * So here is what we do in this formatter: * - If a FAT type is requested from the caller, we try to modify * the cluster size, until the data cluster count is in range - * - If no FAT type is given, we estimate a useful FAT type from + * - If no FAT type is given, we estimate a useful FAT type from * the disk capacity and then adapt the cluster size - */ + */ /* * determine characteristic values: @@ -450,19 +450,19 @@ static int msdos_format_determine_fmt_params */ /* * determine FAT type and sectors per cluster - * depends on + * depends on */ if (ret_val == 0) { fmt_params->sectors_per_cluster = 1; - if ((rqdata != NULL) && + if ((rqdata != NULL) && (rqdata->fattype == MSDOS_FMT_FAT12)) { fmt_params->fattype = FAT_FAT12; } - else if ((rqdata != NULL) && + else if ((rqdata != NULL) && (rqdata->fattype == MSDOS_FMT_FAT16)) { fmt_params->fattype = FAT_FAT16; } - else if ((rqdata != NULL) && + else if ((rqdata != NULL) && (rqdata->fattype == MSDOS_FMT_FAT32)) { fmt_params->fattype = FAT_FAT32; } @@ -477,17 +477,17 @@ static int msdos_format_determine_fmt_params * NOTE: maximum sect_per_clust is arbitrarily choosen with values that * are a compromise concerning capacity and efficency */ - if (fmt_params->totl_sector_cnt + if (fmt_params->totl_sector_cnt < ((uint32_t)FAT_FAT12_MAX_CLN)*8) { fmt_params->fattype = FAT_FAT12; /* start trying with small clusters */ - fmt_params->sectors_per_cluster = 2; + fmt_params->sectors_per_cluster = 2; } - else if (fmt_params->totl_sector_cnt + else if (fmt_params->totl_sector_cnt < ((uint32_t)FAT_FAT16_MAX_CLN)*32) { fmt_params->fattype = FAT_FAT16; /* start trying with small clusters */ - fmt_params->sectors_per_cluster = 2; + fmt_params->sectors_per_cluster = 2; } else { #define ONE_GB (1024L * 1024L * 1024L) @@ -504,10 +504,10 @@ static int msdos_format_determine_fmt_params /* * try to use user requested cluster size */ - if ((rqdata != NULL) && + if ((rqdata != NULL) && (rqdata->sectors_per_cluster > 0)) { - fmt_params->sectors_per_cluster = - rqdata->sectors_per_cluster; + fmt_params->sectors_per_cluster = + rqdata->sectors_per_cluster; } /* * check sectors per cluster. @@ -518,7 +518,7 @@ static int msdos_format_determine_fmt_params for (onebit = 128;onebit >= 1;onebit = onebit>>1) { if (fmt_params->sectors_per_cluster >= onebit) { fmt_params->sectors_per_cluster = onebit; - if (fmt_params->sectors_per_cluster + if (fmt_params->sectors_per_cluster <= 32768L/fmt_params->bytes_per_sector) { /* value is small enough so this value is ok */ onebit = 1; @@ -530,7 +530,7 @@ static int msdos_format_determine_fmt_params if (ret_val == 0) { msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL, "sectors per cluster: %d\n", fmt_params->sectors_per_cluster); - + if (fmt_params->fattype == FAT_FAT32) { /* recommended: for FAT32, always set reserved sector count to 32 */ fmt_params->rsvd_sector_cnt = 32; @@ -548,7 +548,7 @@ static int msdos_format_determine_fmt_params /* recommended: for FAT16, set files per root directory to 512 */ /* for FAT12/FAT16, set files per root directory */ /* must fill up an even count of sectors */ - if ((rqdata != NULL) && + if ((rqdata != NULL) && (rqdata->files_per_root_dir > 0)) { fmt_params->files_per_root_dir = rqdata->files_per_root_dir; } @@ -560,23 +560,23 @@ static int msdos_format_determine_fmt_params fmt_params->files_per_root_dir = 64; } } - fmt_params->files_per_root_dir = (fmt_params->files_per_root_dir + + fmt_params->files_per_root_dir = (fmt_params->files_per_root_dir + (2*fmt_params->bytes_per_sector/ FAT_DIRENTRY_SIZE-1)); - fmt_params->files_per_root_dir -= (fmt_params->files_per_root_dir % + fmt_params->files_per_root_dir -= (fmt_params->files_per_root_dir % (2*fmt_params->bytes_per_sector /FAT_DIRENTRY_SIZE)); } - fmt_params->root_dir_sectors = + fmt_params->root_dir_sectors = (((fmt_params->files_per_root_dir * FAT_DIRENTRY_SIZE) - + fmt_params->bytes_per_sector - 1) + + fmt_params->bytes_per_sector - 1) / fmt_params->bytes_per_sector); } if (ret_val == 0) { - fatdata_sect_cnt = (fmt_params->totl_sector_cnt - - fmt_params->rsvd_sector_cnt - + fatdata_sect_cnt = (fmt_params->totl_sector_cnt - + fmt_params->rsvd_sector_cnt - fmt_params->root_dir_sectors); - + /* * check values to get legal arrangement of FAT type and cluster count */ @@ -596,9 +596,9 @@ static int msdos_format_determine_fmt_params * determine media code */ if (ret_val == 0) { - if ((rqdata != NULL) && + if ((rqdata != NULL) && (rqdata->media != 0)) { - const char valid_media_codes[] = + const char valid_media_codes[] = {0xF0,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}; if (NULL==memchr(valid_media_codes, rqdata->media, @@ -619,18 +619,18 @@ static int msdos_format_determine_fmt_params * for formatting */ if (fmt_params->root_dir_sectors > 0) { - fmt_params->root_dir_start_sec = + fmt_params->root_dir_start_sec = fmt_params->rsvd_sector_cnt - + (fmt_params-> fat_num*fmt_params->sectors_per_fat); + + (fmt_params-> fat_num*fmt_params->sectors_per_fat); fmt_params->root_dir_fmt_sec_cnt = fmt_params->root_dir_sectors; } else { /* * for FAT32: root directory is in cluster 2 */ - fmt_params->root_dir_start_sec = + fmt_params->root_dir_start_sec = fmt_params->rsvd_sector_cnt - + (fmt_params-> fat_num*fmt_params->sectors_per_fat); + + (fmt_params-> fat_num*fmt_params->sectors_per_fat); fmt_params->root_dir_fmt_sec_cnt = fmt_params->sectors_per_cluster; } /* @@ -653,8 +653,8 @@ static int msdos_format_determine_fmt_params } else { /* - * non-printable character in given name, so keep stuck - * at that character and replace all following characters + * non-printable character in given name, so keep stuck + * at that character and replace all following characters * with a ' ' */ *to++=' '; @@ -684,8 +684,8 @@ static int msdos_format_determine_fmt_params } else { /* - * non-printable character in given name, so keep stuck - * at that character and replace all following characters + * non-printable character in given name, so keep stuck + * at that character and replace all following characters * with a ' ' */ *to++=' '; @@ -693,7 +693,7 @@ static int msdos_format_determine_fmt_params *to = '\0'; } } - + /* * determine usable Volume ID */ @@ -754,7 +754,7 @@ static int msdos_format_gen_mbr * with 0xEB,.... */ /* - * fill OEMName + * fill OEMName */ memcpy(FAT_GET_ADDR_BR_OEMNAME(mbr), fmt_params->OEMName, @@ -762,7 +762,7 @@ static int msdos_format_gen_mbr FAT_SET_BR_BYTES_PER_SECTOR(mbr , fmt_params->bytes_per_sector); FAT_SET_BR_SECTORS_PER_CLUSTER(mbr , fmt_params->sectors_per_cluster); FAT_SET_BR_RESERVED_SECTORS_NUM(mbr, fmt_params->rsvd_sector_cnt); - + /* number of FATs on medium */ FAT_SET_BR_FAT_NUM(mbr , 2); /* standard/recommended value */ FAT_SET_BR_FILES_PER_ROOT_DIR(mbr , fmt_params->files_per_root_dir); @@ -778,13 +778,13 @@ static int msdos_format_gen_mbr FAT_SET_BR_SECTORS_PER_FAT(mbr ,fmt_params->sectors_per_fat); FAT_SET_BR_DRVNUM(mbr , 0); /* only needed for INT13... */ FAT_SET_BR_RSVD1(mbr , 0); /* fill with zero */ - FAT_SET_BR_BOOTSIG(mbr , FAT_BR_BOOTSIG_VAL); + FAT_SET_BR_BOOTSIG(mbr , FAT_BR_BOOTSIG_VAL); FAT_SET_BR_VOLID(mbr , fmt_params->vol_id); /* volume id */ memcpy(FAT_GET_ADDR_BR_VOLLAB(mbr), fmt_params->VolLabel, FAT_BR_VOLLAB_SIZE); memcpy(FAT_GET_ADDR_BR_FILSYSTYPE(mbr), - (fmt_params->fattype == FAT_FAT12) + (fmt_params->fattype == FAT_FAT12) ? "FAT12 " : "FAT16 ", FAT_BR_FILSYSTYPE_SIZE); @@ -800,7 +800,7 @@ static int msdos_format_gen_mbr FAT_SET_BR_FAT32_DRVNUM(mbr , 0); /* only needed for INT13... */ FAT_SET_BR_FAT32_RSVD1(mbr , 0); /* fill with zero */ - FAT_SET_BR_FAT32_BOOTSIG(mbr ,FAT_BR_FAT32_BOOTSIG_VAL); + FAT_SET_BR_FAT32_BOOTSIG(mbr ,FAT_BR_FAT32_BOOTSIG_VAL); FAT_SET_BR_FAT32_VOLID(mbr , 0); /* not set */ memset(FAT_GET_ADDR_BR_FAT32_VOLLAB(mbr) ,0,FAT_BR_VOLLAB_SIZE); memcpy(FAT_GET_ADDR_BR_FAT32_FILSYSTYPE(mbr), @@ -820,7 +820,7 @@ static int msdos_format_gen_mbr FAT_SET_VAL8(mbr,2,0x90); /* * FIXME: a nice little PC boot loader would be nice here. - * but where can I get one for free? + * but where can I get one for free? */ /* * Phuuu.... That's it. @@ -847,7 +847,7 @@ static int msdos_format_gen_fsinfo \*=========================================================================*/ { /* - * clear fsinfo sector data + * clear fsinfo sector data */ memset(fsinfo,0,FAT_TOTAL_FSINFO_SIZE); /* @@ -856,8 +856,8 @@ static int msdos_format_gen_fsinfo FAT_SET_FSINFO_LEAD_SIGNATURE (fsinfo,FAT_FSINFO_LEAD_SIGNATURE_VALUE ); FAT_SET_FSINFO_STRUC_SIGNATURE(fsinfo,FAT_FSINFO_STRUC_SIGNATURE_VALUE); FAT_SET_FSINFO_TRAIL_SIGNATURE(fsinfo,FAT_FSINFO_TRAIL_SIGNATURE_VALUE); - /* - * write "empty" values for free cluster count and next cluster number + /* + * write "empty" values for free cluster count and next cluster number */ FAT_SET_FSINFO_FREE_CLUSTER_COUNT(fsinfo+FAT_FSI_INFO, 0xffffffff); @@ -889,7 +889,7 @@ int msdos_format { char tmp_sec[FAT_TOTAL_MBR_SIZE]; int rc; - rtems_disk_device *dd = NULL; + rtems_disk_device *dd = NULL; struct stat stat_buf; int ret_val = 0; int fd = -1; @@ -907,14 +907,14 @@ int msdos_format rc = stat(devname, &stat_buf); ret_val = rc; } - - /* rtems feature: no block devices, all are character devices */ + + /* rtems feature: no block devices, all are character devices */ if ((ret_val == 0) && (!S_ISCHR(stat_buf.st_mode))) { errno = ENOTTY; ret_val = -1; } - + /* check that device is registered as block device and lock it */ if (ret_val == 0) { dd = rtems_disk_obtain(stat_buf.st_rdev); @@ -934,8 +934,8 @@ int msdos_format if (fd == -1) { ret_val= -1; - } - } + } + } /* * compute formatting parameters @@ -958,7 +958,7 @@ int msdos_format 0xe5); } /* - * create master boot record + * create master boot record */ if (ret_val == 0) { /* @@ -975,7 +975,7 @@ int msdos_format "generate MRB sector\n"); ret_val = msdos_format_gen_mbr(tmp_sec,&fmt_params); } - + /* * write master boot record to disk * also write copy of MBR to disk @@ -983,20 +983,20 @@ int msdos_format if (ret_val == 0) { msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL, "write MRB sector\n"); - ret_val = msdos_format_write_sec(fd, - 0, + ret_val = msdos_format_write_sec(fd, + 0, fmt_params.bytes_per_sector, tmp_sec); } - if ((ret_val == 0) && + if ((ret_val == 0) && (fmt_params.mbr_copy_sec != 0)) { /* * write copy of MBR */ msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL, "write back up MRB sector\n"); - ret_val = msdos_format_write_sec(fd, - fmt_params.mbr_copy_sec , + ret_val = msdos_format_write_sec(fd, + fmt_params.mbr_copy_sec , fmt_params.bytes_per_sector, tmp_sec); } @@ -1004,7 +1004,7 @@ int msdos_format /* * for FAT32: initialize info sector on disk */ - if ((ret_val == 0) && + if ((ret_val == 0) && (fmt_params.fsinfo_sec != 0)) { ret_val = msdos_format_gen_fsinfo(tmp_sec); } @@ -1013,7 +1013,7 @@ int msdos_format */ if ((ret_val == 0) && (fmt_params.fsinfo_sec != 0)) { - ret_val = msdos_format_write_sec(fd, + ret_val = msdos_format_write_sec(fd, fmt_params.fsinfo_sec, fmt_params.bytes_per_sector, tmp_sec); @@ -1058,7 +1058,7 @@ int msdos_format tmp_sec); } /* - * write FAT entry 0 as (0xffffff00|Media_type)EOC, + * write FAT entry 0 as (0xffffff00|Media_type)EOC, * write FAT entry 1 as EOC * allocate directory in a FAT32 FS */ diff --git a/cpukit/libfs/src/dosfs/msdos_misc.c b/cpukit/libfs/src/dosfs/msdos_misc.c index 67ce4a11e3..003d2f57f4 100644 --- a/cpukit/libfs/src/dosfs/msdos_misc.c +++ b/cpukit/libfs/src/dosfs/msdos_misc.c @@ -68,7 +68,7 @@ msdos_is_valid_name_char(const char ch) if ((ch == '.') || isalnum(ch) || (strchr("$%'-_@~`!(){}^#&", ch) != NULL)) return MSDOS_NAME_SHORT; - + return MSDOS_NAME_INVALID; } @@ -143,19 +143,19 @@ msdos_name_type(const char *name, int name_len) uppercase = true; else if ((*name >= 'a') && (*name <= 'z')) lowercase = true; - + count++; name++; } if (lowercase && uppercase) return MSDOS_NAME_LONG; - + return MSDOS_NAME_SHORT; } /* msdos_long_to_short -- - * Routine to creates a short name from a long. Start the end of the + * Routine to creates a short name from a long. Start the end of the * * PARAMETERS: * name - name to check @@ -183,7 +183,7 @@ msdos_long_to_short(const char *lfn, int lfn_len, char* sfn, int sfn_len) sfn[0] = '.'; return MSDOS_NAME_SHORT; } - + if ((lfn[0] == '.') && (lfn[1] == '.') && (lfn_len == 2)) { sfn[0] = sfn[1] = '.'; @@ -203,14 +203,14 @@ msdos_long_to_short(const char *lfn, int lfn_len, char* sfn, int sfn_len) /* * Is this a short name ? */ - + type = msdos_name_type (lfn, lfn_len); if (type == MSDOS_NAME_INVALID) return MSDOS_NAME_INVALID; - + msdos_filename_unix2dos (lfn, lfn_len, sfn); - + return type; } @@ -251,7 +251,7 @@ msdos_get_token(const char *path, } *ret_token = path; - + /* * If it is just a separator then it is the current dir. */ @@ -350,7 +350,7 @@ msdos_find_name( return rc; fat_fd->dir_pos = dir_pos; - + /* * I don't like this if, but: we should do it, or should write new file * size and first cluster num to the disk after each write operation @@ -824,7 +824,7 @@ msdos_set_first_char4file_name( dir_block_size = fs_info->fat.vol.rdir_size; else dir_block_size = fs_info->fat.vol.bpc; - + if (dir_pos->lname.cln == FAT_FILE_SHORT_NAME) start = dir_pos->sname; @@ -1001,16 +1001,16 @@ int msdos_find_name_in_fat_file( assert(name_len > 0); fat_dir_pos_init(dir_pos); - + lfn_start.cln = lfn_start.ofs = FAT_FILE_SHORT_NAME; - + /* * If the file name is long how many short directory * entries are needed ? */ if (name_type == MSDOS_NAME_LONG) lfn_entries = ((name_len - 1) + MSDOS_LFN_LEN_PER_ENTRY) / MSDOS_LFN_LEN_PER_ENTRY; - + if (FAT_FD_OF_ROOT_DIR(fat_fd) && (fs_info->fat.vol.type & (FAT_FAT12 | FAT_FAT16))) bts2rd = fat_fd->fat_file_size; @@ -1035,7 +1035,7 @@ int msdos_find_name_in_fat_file( #if MSDOS_FIND_PRINT printf ("MSFS:[2] dir_offset:%li\n", dir_offset); #endif - + if (ret < MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE) rtems_set_errno_and_return_minus_one(EIO); @@ -1111,7 +1111,7 @@ int msdos_find_name_in_fat_file( * Remainder is not empty so is this entry empty ? */ empty_space_count++; - + if (empty_space_count == (lfn_entries + 1)) empty_space_found = true; } @@ -1176,7 +1176,7 @@ int msdos_find_name_in_fat_file( if (lfn_entries != (*MSDOS_DIR_ENTRY_TYPE(entry) & MSDOS_LAST_LONG_ENTRY_MASK)) continue; - + /* * Get the checksum of the short entry. */ @@ -1184,7 +1184,7 @@ int msdos_find_name_in_fat_file( lfn_start.ofs = dir_entry; lfn_entry = lfn_entries; lfn_checksum = *MSDOS_DIR_LFN_CHECKSUM(entry); - + #if MSDOS_FIND_PRINT printf ("MSFS:[4.3] lfn_checksum:%i\n", *MSDOS_DIR_LFN_CHECKSUM(entry)); @@ -1211,7 +1211,7 @@ int msdos_find_name_in_fat_file( lfn_entry--; o = lfn_entry * MSDOS_LFN_LEN_PER_ENTRY; p = entry + 1; - + #if MSDOS_FIND_PRINT printf ("MSFS:[5] lfne:%i\n", lfn_entry); #endif @@ -1233,7 +1233,7 @@ int msdos_find_name_in_fat_file( lfn_start.cln = FAT_FILE_SHORT_NAME; break; } - + if (((o + i) >= name_len) || (*p != name[o + i])) { lfn_start.cln = FAT_FILE_SHORT_NAME; @@ -1256,7 +1256,7 @@ int msdos_find_name_in_fat_file( lfn_matched = ((lfn_entry == 0) && (lfn_start.cln != FAT_FILE_SHORT_NAME)); - + #if MSDOS_FIND_PRINT printf ("MSFS:[8.1] lfn_matched:%i\n", lfn_matched); #endif @@ -1309,7 +1309,7 @@ int msdos_find_name_in_fat_file( return rc; dir_pos->sname.ofs = dir_entry; - + if (lfn_start.cln != FAT_FILE_SHORT_NAME) { rc = fat_file_ioctl(mt_entry, fat_fd, F_CLU_NUM, @@ -1318,7 +1318,7 @@ int msdos_find_name_in_fat_file( if (rc != RC_OK) return rc; } - + dir_pos->lname.cln = lfn_start.cln; dir_pos->lname.ofs = lfn_start.ofs; @@ -1326,7 +1326,7 @@ int msdos_find_name_in_fat_file( MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE); return RC_OK; } - + lfn_start.cln = FAT_FILE_SHORT_NAME; lfn_matched = false; } @@ -1363,7 +1363,7 @@ int msdos_find_name_in_fat_file( int i; int slot = (((empty_space_offset * bts2rd) + empty_space_entry) / MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE) + lfn_entries + 1; - + msdos_short_name_hex(MSDOS_DIR_NAME(name_dir_entry), slot); for (i = 0; i < 11; i++, p++) @@ -1408,7 +1408,7 @@ int msdos_find_name_in_fat_file( while (lfn_entry < (lfn_entries + 1)) { int length = 0; - + if (read_cluster) { uint32_t new_length; @@ -1429,7 +1429,7 @@ int msdos_find_name_in_fat_file( #endif ret = fat_file_extend (mt_entry, fat_fd, empty_space_offset * bts2rd, &new_length); - + if (ret != RC_OK) return ret; @@ -1451,11 +1451,11 @@ int msdos_find_name_in_fat_file( rtems_set_errno_and_return_minus_one(EIO); } } - + #if MSDOS_FIND_PRINT printf ("MSFS:[10] eso:%li\n", empty_space_offset); #endif - + for (dir_entry = empty_space_entry; dir_entry < bts2rd; dir_entry += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE) @@ -1467,7 +1467,7 @@ int msdos_find_name_in_fat_file( length += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE; lfn_entry++; - + #if MSDOS_FIND_PRINT printf ("MSFS:[10] de:%li(%li) length:%i lfn_entry:%i\n", dir_entry, (dir_entry / MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE), @@ -1495,7 +1495,7 @@ int msdos_find_name_in_fat_file( if (rc != RC_OK) return rc; } - + dir_pos->lname.cln = lfn_start.cln; dir_pos->lname.ofs = lfn_start.ofs; @@ -1516,23 +1516,23 @@ int msdos_find_name_in_fat_file( lfn_start.cln = empty_space_offset; lfn_start.ofs = dir_entry; } - + /* * Clear the entry before loading the data. */ memset (entry, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE); *MSDOS_DIR_LFN_CHECKSUM(entry) = lfn_checksum; - + p = entry + 1; n = name + (lfn_entries - lfn_entry) * MSDOS_LFN_LEN_PER_ENTRY; - + for (i = 0; i < MSDOS_LFN_LEN_PER_ENTRY; i++) { *p = *n; if (*n != 0) n++; - + switch (i) { case 4: @@ -1563,7 +1563,7 @@ int msdos_find_name_in_fat_file( empty_space_entry = 0; read_cluster = true; } - + return 0; } @@ -1616,7 +1616,7 @@ int msdos_find_node_by_cluster_num_in_fat_file( for (i = 0; i < bts2rd; i += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE) { char* entry = (char*) fs_info->cl_buf + i; - + /* if this and all rest entries are empty - return not-found */ if ((*MSDOS_DIR_ENTRY_TYPE(entry)) == MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY) @@ -1639,7 +1639,7 @@ int msdos_find_node_by_cluster_num_in_fat_file( dir_pos->sname.ofs = i; dir_pos->lname.cln = FAT_FILE_SHORT_NAME; dir_pos->lname.ofs = FAT_FILE_SHORT_NAME; - + memcpy(dir_entry, entry, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE); return RC_OK; diff --git a/cpukit/libfs/src/dosfs/msdos_mknod.c b/cpukit/libfs/src/dosfs/msdos_mknod.c index 421d873136..ad4ad50d00 100644 --- a/cpukit/libfs/src/dosfs/msdos_mknod.c +++ b/cpukit/libfs/src/dosfs/msdos_mknod.c @@ -56,7 +56,7 @@ int msdos_mknod( rtems_status_code sc = RTEMS_SUCCESSFUL; msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info; msdos_token_types_t type = 0; - + /* * Figure out what type of msdos node this is. */ |