forked from Imagelibrary/rtems
2010-10-11 Chris Johns <chrisj@rtems.org>
* libfs/src/rfs/rtems-rfs-trace.c,
libfs/src/rfs/rtems-rfs-trace.h: Add inode-delete.
* libfs/src/rfs/rtems-rfs-shell.c: Fix formatting.
* libfs/src/rfs/rtems-rfs-rtems-dir.c: Use ssize_t. Fix
spelling.
* libfs/src/rfs/rtems-rfs-block.c: Fix
rtems_rfs_block_get_bpos to
return the position correctly. A bpos does not have any
special
processing. Do no reset the buffer handle when shrinking
indirectly.
* libfs/src/rfs/rtems-rfs-inode.c: Add trace.
* libfs/src/rfs/rtems-rfs-format.c: Fix comments.
* libfs/src/rfs/rtems-rfs-group.c: Limit the inodes to the
blocks
in a group so the accounting works.
* libfs/src/rfs/rtems-rfs-dir.c: PR 1705. Fix handling the
offsets
when deleting an entry.
* libfs/src/rfs/rtems-rfs-buffer.h: Remove
rtems_rfs_buffer_handle_reset. It is not needed and dangerous.
* cpukit/libmisc/untar/untar.c: Merge 4.11 pax fix. This fix also
supports MacOS's tar.
This commit is contained in:
@@ -1,3 +1,29 @@
|
|||||||
|
2010-10-11 Chris Johns <chrisj@rtems.org>
|
||||||
|
|
||||||
|
* libfs/src/rfs/rtems-rfs-trace.c,
|
||||||
|
libfs/src/rfs/rtems-rfs-trace.h: Add inode-delete.
|
||||||
|
* libfs/src/rfs/rtems-rfs-shell.c: Fix formatting.
|
||||||
|
* libfs/src/rfs/rtems-rfs-rtems-dir.c: Use ssize_t. Fix
|
||||||
|
spelling.
|
||||||
|
* libfs/src/rfs/rtems-rfs-block.c: Fix
|
||||||
|
rtems_rfs_block_get_bpos to
|
||||||
|
return the position correctly. A bpos does not have any
|
||||||
|
special
|
||||||
|
processing. Do no reset the buffer handle when shrinking
|
||||||
|
indirectly.
|
||||||
|
* libfs/src/rfs/rtems-rfs-inode.c: Add trace.
|
||||||
|
* libfs/src/rfs/rtems-rfs-format.c: Fix comments.
|
||||||
|
* libfs/src/rfs/rtems-rfs-group.c: Limit the inodes to the
|
||||||
|
blocks
|
||||||
|
in a group so the accounting works.
|
||||||
|
* libfs/src/rfs/rtems-rfs-dir.c: PR 1705. Fix handling the
|
||||||
|
offsets
|
||||||
|
when deleting an entry.
|
||||||
|
* libfs/src/rfs/rtems-rfs-buffer.h: Remove
|
||||||
|
rtems_rfs_buffer_handle_reset. It is not needed and dangerous.
|
||||||
|
* cpukit/libmisc/untar/untar.c: Merge 4.11 pax fix. This fix also
|
||||||
|
supports MacOS's tar.
|
||||||
|
|
||||||
2010-09-29 Ralf Corsépius <ralf.corsepius@rtems.org>
|
2010-09-29 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||||
|
|
||||||
* automake/compile.am: Remove non release-suitable warning flags.
|
* automake/compile.am: Remove non release-suitable warning flags.
|
||||||
|
|||||||
@@ -46,18 +46,19 @@
|
|||||||
#include <rtems/rfs/rtems-rfs-inode.h>
|
#include <rtems/rfs/rtems-rfs-inode.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
rtems_rfs_block_get_bpos (rtems_rfs_file_system* fs,
|
rtems_rfs_block_get_bpos (rtems_rfs_file_system* fs,
|
||||||
rtems_rfs_pos pos,
|
rtems_rfs_pos pos,
|
||||||
rtems_rfs_block_pos* bpos)
|
rtems_rfs_block_pos* bpos)
|
||||||
{
|
{
|
||||||
bpos->bno = pos / rtems_rfs_fs_block_size (fs);
|
bpos->bno = pos / rtems_rfs_fs_block_size (fs);
|
||||||
bpos->boff = pos % rtems_rfs_fs_block_size (fs);
|
bpos->boff = pos % rtems_rfs_fs_block_size (fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
rtems_rfs_pos
|
rtems_rfs_pos
|
||||||
rtems_rfs_block_get_pos (rtems_rfs_file_system* fs,
|
rtems_rfs_block_get_pos (rtems_rfs_file_system* fs,
|
||||||
rtems_rfs_block_pos* bpos)
|
rtems_rfs_block_pos* bpos)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
rtems_rfs_pos pos = 0;
|
rtems_rfs_pos pos = 0;
|
||||||
if (bpos->bno)
|
if (bpos->bno)
|
||||||
{
|
{
|
||||||
@@ -66,13 +67,17 @@ rtems_rfs_block_get_pos (rtems_rfs_file_system* fs,
|
|||||||
pos = rtems_rfs_fs_block_size (fs);
|
pos = rtems_rfs_fs_block_size (fs);
|
||||||
pos += (bpos->bno - 1) * rtems_rfs_fs_block_size (fs);
|
pos += (bpos->bno - 1) * rtems_rfs_fs_block_size (fs);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
rtems_rfs_pos pos;
|
||||||
|
pos = (bpos->bno * rtems_rfs_fs_block_size (fs)) + bpos->boff;
|
||||||
|
#endif
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rtems_rfs_block_get_block_size (rtems_rfs_file_system* fs,
|
rtems_rfs_block_get_block_size (rtems_rfs_file_system* fs,
|
||||||
rtems_rfs_pos pos,
|
rtems_rfs_pos pos,
|
||||||
rtems_rfs_block_size* size)
|
rtems_rfs_block_size* size)
|
||||||
{
|
{
|
||||||
if (pos == 0)
|
if (pos == 0)
|
||||||
rtems_rfs_block_set_size_zero (size);
|
rtems_rfs_block_set_size_zero (size);
|
||||||
|
|||||||
@@ -127,6 +127,10 @@ rtems_rfs_dir_lookup_ino (rtems_rfs_file_system* fs,
|
|||||||
{
|
{
|
||||||
uint8_t* entry;
|
uint8_t* entry;
|
||||||
|
|
||||||
|
if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_LOOKUP_INO))
|
||||||
|
printf ("rtems-rfs: dir-lookup-ino: block read, ino=%" PRIu32 " bno=%" PRId32 "\n",
|
||||||
|
rtems_rfs_inode_ino (inode), map.bpos.bno);
|
||||||
|
|
||||||
rc = rtems_rfs_buffer_handle_request (fs, &entries, block, true);
|
rc = rtems_rfs_buffer_handle_request (fs, &entries, block, true);
|
||||||
if (rc > 0)
|
if (rc > 0)
|
||||||
{
|
{
|
||||||
@@ -171,8 +175,9 @@ rtems_rfs_dir_lookup_ino (rtems_rfs_file_system* fs,
|
|||||||
{
|
{
|
||||||
if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_LOOKUP_INO_CHECK))
|
if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_LOOKUP_INO_CHECK))
|
||||||
printf ("rtems-rfs: dir-lookup-ino: "
|
printf ("rtems-rfs: dir-lookup-ino: "
|
||||||
"checking entry for ino %" PRId32 ": off=%04" PRIx32 " length:%d ino:%" PRId32 "\n",
|
"checking entry for ino %" PRId32 ": bno=%04" PRIx32 "/off=%04" PRIx32
|
||||||
rtems_rfs_inode_ino (inode), map.bpos.boff,
|
" length:%d ino:%" PRId32 "\n",
|
||||||
|
rtems_rfs_inode_ino (inode), map.bpos.bno, map.bpos.boff,
|
||||||
elength, rtems_rfs_dir_entry_ino (entry));
|
elength, rtems_rfs_dir_entry_ino (entry));
|
||||||
|
|
||||||
if (memcmp (entry + RTEMS_RFS_DIR_ENTRY_SIZE, name, length) == 0)
|
if (memcmp (entry + RTEMS_RFS_DIR_ENTRY_SIZE, name, length) == 0)
|
||||||
@@ -414,7 +419,7 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
|
|||||||
while (rc == 0)
|
while (rc == 0)
|
||||||
{
|
{
|
||||||
uint8_t* entry;
|
uint8_t* entry;
|
||||||
int offset;
|
int eoffset;
|
||||||
|
|
||||||
rc = rtems_rfs_buffer_handle_request (fs, &buffer, block, true);
|
rc = rtems_rfs_buffer_handle_request (fs, &buffer, block, true);
|
||||||
if (rc > 0)
|
if (rc > 0)
|
||||||
@@ -425,11 +430,19 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
|
|||||||
rtems_rfs_inode_ino (dir), rc, strerror (rc));
|
rtems_rfs_inode_ino (dir), rc, strerror (rc));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we are searching start at the beginning of the block. If not searching
|
||||||
|
* skip to the offset in the block.
|
||||||
|
*/
|
||||||
|
if (search)
|
||||||
|
eoffset = 0;
|
||||||
|
else
|
||||||
|
eoffset = offset % rtems_rfs_fs_block_size (fs);
|
||||||
|
|
||||||
entry = rtems_rfs_buffer_data (&buffer);
|
entry = rtems_rfs_buffer_data (&buffer) + eoffset;
|
||||||
offset = 0;
|
|
||||||
|
|
||||||
while (offset < (rtems_rfs_fs_block_size (fs) - RTEMS_RFS_DIR_ENTRY_SIZE))
|
while (eoffset < (rtems_rfs_fs_block_size (fs) - RTEMS_RFS_DIR_ENTRY_SIZE))
|
||||||
{
|
{
|
||||||
rtems_rfs_ino eino;
|
rtems_rfs_ino eino;
|
||||||
int elength;
|
int elength;
|
||||||
@@ -444,8 +457,9 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
|
|||||||
{
|
{
|
||||||
if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_DEL_ENTRY))
|
if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_DEL_ENTRY))
|
||||||
printf ("rtems-rfs: dir-del-entry: "
|
printf ("rtems-rfs: dir-del-entry: "
|
||||||
"bad length or ino for ino %" PRIu32 ": %u/%" PRId32 " @ %04x\n",
|
"bad length or ino for ino %" PRIu32 ": %u/%" PRId32
|
||||||
rtems_rfs_inode_ino (dir), elength, eino, offset);
|
" @ %" PRIu32 ".%04x\n",
|
||||||
|
rtems_rfs_inode_ino (dir), elength, eino, block, eoffset);
|
||||||
rc = EIO;
|
rc = EIO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -453,7 +467,7 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
|
|||||||
if (ino == rtems_rfs_dir_entry_ino (entry))
|
if (ino == rtems_rfs_dir_entry_ino (entry))
|
||||||
{
|
{
|
||||||
uint32_t remaining;
|
uint32_t remaining;
|
||||||
remaining = rtems_rfs_fs_block_size (fs) - (offset + elength);
|
remaining = rtems_rfs_fs_block_size (fs) - (eoffset + elength);
|
||||||
memmove (entry, entry + elength, remaining);
|
memmove (entry, entry + elength, remaining);
|
||||||
memset (entry + remaining, 0xff, elength);
|
memset (entry + remaining, 0xff, elength);
|
||||||
|
|
||||||
@@ -468,12 +482,13 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
|
|||||||
|
|
||||||
if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_DEL_ENTRY))
|
if (rtems_rfs_trace (RTEMS_RFS_TRACE_DIR_DEL_ENTRY))
|
||||||
printf ("rtems-rfs: dir-del-entry: "
|
printf ("rtems-rfs: dir-del-entry: "
|
||||||
"last block free for ino %" PRIu32 ": elength=%i offset=%d last=%s\n",
|
"last block free for ino %" PRIu32 ": elength=%i block=%" PRIu32
|
||||||
ino, elength, offset,
|
" offset=%d last=%s\n",
|
||||||
|
ino, elength, block, eoffset,
|
||||||
rtems_rfs_block_map_last (&map) ? "yes" : "no");
|
rtems_rfs_block_map_last (&map) ? "yes" : "no");
|
||||||
|
|
||||||
if ((elength == RTEMS_RFS_DIR_ENTRY_EMPTY) &&
|
if ((elength == RTEMS_RFS_DIR_ENTRY_EMPTY) &&
|
||||||
(offset == 0) && rtems_rfs_block_map_last (&map))
|
(eoffset == 0) && rtems_rfs_block_map_last (&map))
|
||||||
{
|
{
|
||||||
rc = rtems_rfs_block_map_shrink (fs, &map, 1);
|
rc = rtems_rfs_block_map_shrink (fs, &map, 1);
|
||||||
if (rc > 0)
|
if (rc > 0)
|
||||||
@@ -497,8 +512,8 @@ rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry += elength;
|
entry += elength;
|
||||||
offset += elength;
|
eoffset += elength;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
/**
|
/**
|
||||||
* Is tracing enabled ?
|
* Is tracing enabled ?
|
||||||
*/
|
*/
|
||||||
#define RTEMS_RFS_TRACE 0
|
#define RTEMS_RFS_TRACE 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the mask.
|
* The type of the mask.
|
||||||
|
|||||||
@@ -39,7 +39,8 @@
|
|||||||
* 148 8 bytes Header checksum (in octal ascii)
|
* 148 8 bytes Header checksum (in octal ascii)
|
||||||
* 156 1 bytes Link flag
|
* 156 1 bytes Link flag
|
||||||
* 157 100 bytes Linkname ('\0' terminated, 99 maxmum length)
|
* 157 100 bytes Linkname ('\0' terminated, 99 maxmum length)
|
||||||
* 257 8 bytes Magic ("ustar \0")
|
* 257 8 bytes Magic PAX ("ustar\0" + 2 bytes padding)
|
||||||
|
* 257 8 bytes Magic GNU tar ("ustar \0")
|
||||||
* 265 32 bytes User name ('\0' terminated, 31 maxmum length)
|
* 265 32 bytes User name ('\0' terminated, 31 maxmum length)
|
||||||
* 297 32 bytes Group name ('\0' terminated, 31 maxmum length)
|
* 297 32 bytes Group name ('\0' terminated, 31 maxmum length)
|
||||||
* 329 8 bytes Major device ID (in octal ascii)
|
* 329 8 bytes Major device ID (in octal ascii)
|
||||||
@@ -143,7 +144,7 @@ Untar_FromMemory(
|
|||||||
/* Read the header */
|
/* Read the header */
|
||||||
bufr = &tar_ptr[ptr];
|
bufr = &tar_ptr[ptr];
|
||||||
ptr += 512;
|
ptr += 512;
|
||||||
if (strncmp(&bufr[257], "ustar ", 7))
|
if (strncmp(&bufr[257], "ustar", 5))
|
||||||
{
|
{
|
||||||
retval = UNTAR_SUCCESSFUL;
|
retval = UNTAR_SUCCESSFUL;
|
||||||
break;
|
break;
|
||||||
@@ -253,7 +254,7 @@ Untar_FromFile(
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char *bufr;
|
char *bufr;
|
||||||
size_t n;
|
ssize_t n;
|
||||||
char fname[100];
|
char fname[100];
|
||||||
char linkname[100];
|
char linkname[100];
|
||||||
int sum;
|
int sum;
|
||||||
@@ -264,15 +265,17 @@ Untar_FromFile(
|
|||||||
unsigned long size;
|
unsigned long size;
|
||||||
unsigned char linkflag;
|
unsigned char linkflag;
|
||||||
|
|
||||||
|
|
||||||
retval = UNTAR_SUCCESSFUL;
|
retval = UNTAR_SUCCESSFUL;
|
||||||
bufr = (char *)malloc(512);
|
|
||||||
if (bufr == NULL)
|
if ((fd = open(tar_name, O_RDONLY)) < 0) {
|
||||||
{
|
return UNTAR_FAIL;
|
||||||
return(UNTAR_FAIL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open(tar_name, O_RDONLY);
|
bufr = (char *)malloc(512);
|
||||||
|
if (bufr == NULL) {
|
||||||
|
return(UNTAR_FAIL);
|
||||||
|
}
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
/* Read the header */
|
/* Read the header */
|
||||||
@@ -283,7 +286,7 @@ Untar_FromFile(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(&bufr[257], "ustar ", 7))
|
if (strncmp(&bufr[257], "ustar", 5))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user