[RTEMS Project] #2757: truncate() is broken for FAT
RTEMS trac
trac at rtems.org
Tue Jul 12 10:32:39 UTC 2016
#2757: truncate() is broken for FAT
--------------------------+--------------------
Reporter: snob-wolpike | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 4.11.1
Component: filesystem | Version: 4.11
Severity: normal | Keywords:
--------------------------+--------------------
Steps to reproduce:
- Under RTEMS truncate existing file to zero length.
- Run chkdsk under any other OS (Linux, MacOSX, Win):
{{{
$ sudo fsck_msdos /dev/rdisk3s1
** /dev/rdisk3s1
** Phase 1 - Preparing FAT
** Phase 2 - Checking Directories
/testwrite starts with free cluster
Truncate? [yn] n
/testwrite: Cluster chain starting at 3030 ends with cluster marked free
Truncate? [yn] n
/testwrite has too many clusters allocated (logical=0, physical=2048)
Drop superfluous clusters? [yn] n
}}}
Sample test code:
{{{
#!c
FILE* f = fopen(TEST_FILENAME, "wb");
if(f == 0)
{
printk("fopen() failed: %i %s\n", errno, strerror(errno));
exit(0);
}
for(int i = 0; i < 256 * 1024; i += 1)
fprintf(f, "Test message buffer bum %i\n", i);
fflush(f);
fclose(f);
fflush(NULL);
if(truncate(TEST_FILENAME, 0) != 0)
{
printk("truncate() failed: %i %s\n", errno, strerror(errno));
exit(0);
}
}}}
Both 4.11 and 4.12 affected
--
Ticket URL: <http://devel.rtems.org/ticket/2757>
RTEMS Project <http://www.rtems.org/>
RTEMS Project
More information about the bugs
mailing list