summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/dosfs/fat_file.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2009-04-29 08:31:27 +0000
committerChris Johns <chrisj@rtems.org>2009-04-29 08:31:27 +0000
commit07d6fd513f1c4d3c6905c880948671de1181fac2 (patch)
tree4dabf3fdd0b056bba7b0e9beb40f01277e5c2776 /cpukit/libfs/src/dosfs/fat_file.c
parent2009-04-28 Chris Johns <chrisj@rtems.org> (diff)
downloadrtems-07d6fd513f1c4d3c6905c880948671de1181fac2.tar.bz2
2009-04-29 Chris Johns <chrisj@rtems.org>
* libcsupport/include/rtems/libio.h: Add rtems_off64_t for internal use. Update the internal off_t to the 64bit offset. * libnetworking/lib/ftpfs.c, libnetworking/lib/tftpDriver.c, libfs/src/nfsclient/src/nfs.c, libfs/src/imfs/imfs_fifo.c, libfs/src/imfs/memfile.c, libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs.h, libfs/src/imfs/deviceio.c: Change off_t to rtems_off64_t. * libmisc/shell/main_msdosfmt.c: Add an info level so the format code can tell the user what is happening. Add more options to control the format configuration. * libfs/src/dosfs/msdos_format.c: Add a print function to display the format progress and print statements. Select a better default cluster size depending on the size of the disk. This lowers the size of the FAT on large disks. Read and maintain the MRB partition information. * libfs/src/dosfs/dosfs.h, libfs/src/dosfs/fat.h, libfs/src/dosfs/fat_file.c, libfs/src/dosfs/fat_file.h, libfs/src/dosfs/msdos.h, libfs/src/dosfs/msdos_conv.c, libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_file.c, libfs/src/dosfs/msdos_handlers_dir.c, libfs/src/dosfs/msdos_handlers_file.c, libfs/src/dosfs/msdos_init.c, libfs/src/dosfs/msdos_initsupp.c, libfs/src/dosfs/msdos_misc.c, libfs/src/dosfs/msdos_mknod.c: Add long file name support. Change off_t to rtems_off64_t.
Diffstat (limited to 'cpukit/libfs/src/dosfs/fat_file.c')
-rw-r--r--cpukit/libfs/src/dosfs/fat_file.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/cpukit/libfs/src/dosfs/fat_file.c b/cpukit/libfs/src/dosfs/fat_file.c
index 42204bacd7..b1a642f54b 100644
--- a/cpukit/libfs/src/dosfs/fat_file.c
+++ b/cpukit/libfs/src/dosfs/fat_file.c
@@ -33,20 +33,20 @@
#include "fat_file.h"
static inline void
-_hash_insert(Chain_Control *hash, uint32_t key1, uint32_t key2,
+_hash_insert(rtems_chain_control *hash, uint32_t key1, uint32_t key2,
fat_file_fd_t *el);
static inline void
-_hash_delete(Chain_Control *hash, uint32_t key1, uint32_t key2,
+_hash_delete(rtems_chain_control *hash, uint32_t key1, uint32_t key2,
fat_file_fd_t *el);
static inline int
_hash_search(
rtems_filesystem_mount_table_entry_t *mt_entry,
- Chain_Control *hash,
+ rtems_chain_control *hash,
uint32_t key1,
uint32_t key2,
- fat_file_fd_t **ret
+ fat_file_fd_t **ret
);
static off_t
@@ -75,8 +75,7 @@ fat_file_lseek(
*
* PARAMETERS:
* mt_entry - mount table entry
- * cln - cluster num of the node
- * ofs - offset of the node
+ * pos - cluster and offset of the node
* fat_fd - placeholder for returned fat-file descriptor
*
* RETURNS:
@@ -86,8 +85,7 @@ fat_file_lseek(
int
fat_file_open(
rtems_filesystem_mount_table_entry_t *mt_entry,
- uint32_t cln,
- uint32_t ofs,
+ fat_dir_pos_t *dir_pos,
fat_file_fd_t **fat_fd
)
{
@@ -97,7 +95,7 @@ fat_file_open(
uint32_t key = 0;
/* construct key */
- key = fat_construct_key(mt_entry, cln, ofs);
+ key = fat_construct_key(mt_entry, &dir_pos->sname);
/* access "valid" hash table */
rc = _hash_search(mt_entry, fs_info->vhash, key, 0, &lfat_fd);
@@ -116,10 +114,14 @@ fat_file_open(
if ( lfat_fd == NULL )
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;
+ lfat_fd->dir_pos = *dir_pos;
+
if ( rc != RC_OK )
lfat_fd->ino = key;
else
@@ -138,7 +140,6 @@ fat_file_open(
}
_hash_insert(fs_info->vhash, key, lfat_fd->ino, lfat_fd);
-
/*
* other fields of fat-file descriptor will be initialized on upper
* level
@@ -203,7 +204,7 @@ fat_file_close(
return rc;
}
- key = fat_construct_key(mt_entry, fat_fd->info_cln, fat_fd->info_ofs);
+ key = fat_construct_key(mt_entry, &fat_fd->dir_pos.sname);
if (fat_fd->flags & FAT_FILE_REMOVED)
{
@@ -582,6 +583,8 @@ fat_file_extend(
}
}
+ fat_fd->fat_file_size = new_length;
+
return RC_OK;
}
@@ -736,7 +739,7 @@ fat_file_mark_removed(
fat_fs_info_t *fs_info = mt_entry->fs_info;
uint32_t key = 0;
- key = fat_construct_key(mt_entry, fat_fd->info_cln, fat_fd->info_ofs);
+ key = fat_construct_key(mt_entry, &fat_fd->dir_pos.sname);
_hash_delete(fs_info->vhash, key, fat_fd->ino, fat_fd);
@@ -869,10 +872,10 @@ fat_file_size(
* None
*/
static inline void
-_hash_insert(Chain_Control *hash, uint32_t key1, uint32_t key2,
+_hash_insert(rtems_chain_control *hash, uint32_t key1, uint32_t key2,
fat_file_fd_t *el)
{
- _Chain_Append((hash) + ((key1) % FAT_HASH_MODULE), &(el)->link);
+ rtems_chain_append((hash) + ((key1) % FAT_HASH_MODULE), &(el)->link);
}
@@ -889,10 +892,10 @@ _hash_insert(Chain_Control *hash, uint32_t key1, uint32_t key2,
* None
*/
static inline void
-_hash_delete(Chain_Control *hash, uint32_t key1, uint32_t key2,
+_hash_delete(rtems_chain_control *hash, uint32_t key1, uint32_t key2,
fat_file_fd_t *el)
{
- _Chain_Extract(&(el)->link);
+ rtems_chain_extract(&(el)->link);
}
/* _hash_search --
@@ -912,20 +915,19 @@ _hash_delete(Chain_Control *hash, uint32_t key1, uint32_t key2,
static inline int
_hash_search(
rtems_filesystem_mount_table_entry_t *mt_entry,
- Chain_Control *hash,
+ rtems_chain_control *hash,
uint32_t key1,
uint32_t key2,
fat_file_fd_t **ret
)
{
- uint32_t mod = (key1) % FAT_HASH_MODULE;
- Chain_Node *the_node = ((Chain_Control *)((hash) + mod))->first;
+ uint32_t mod = (key1) % FAT_HASH_MODULE;
+ rtems_chain_node *the_node = ((rtems_chain_control *)((hash) + mod))->first;
- for ( ; !_Chain_Is_tail((hash) + mod, the_node) ; )
+ for ( ; !rtems_chain_is_tail((hash) + mod, the_node) ; )
{
fat_file_fd_t *ffd = (fat_file_fd_t *)the_node;
- uint32_t ck =
- fat_construct_key(mt_entry, ffd->info_cln, ffd->info_ofs);
+ uint32_t ck = fat_construct_key(mt_entry, &ffd->dir_pos.sname);
if ( (key1) == ck)
{