Dear developer.
When using ntfs-3g, I found it is very stable to create files on ntfs
volume. Thanks for your effort!
But I found a issue when use my program, the following is the code and
steps:
/* createf.c
* gcc -o createf createf.c
*/
#define _LARGEFILE64_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
int main(int argc, char* argv[])
{
char *new_file;
long length_mb;
long long length;
char buf[512];
int ret = 0;
int fd = -1;
if(argc < 3){
printf( "Usage: createf <file name> <file length in MB>\n");
return 1;
}
new_file = argv[1];
length_mb = atoi( argv[2] );
if( length_mb < 1 ){
printf( "Invalid length in MB: %s\n", argv[2] );
return 1;
}
length = length_mb << 20;
fd = open( new_file, O_CREAT | O_WRONLY);
if( fd < 0 ){
printf( "open file %s failed, error: %s\n", strerror( errno ) );
return 1;
}
if( lseek64( fd, (off64_t)(length - 512), SEEK_SET ) != (off64_t)(length
- 512) ){
ret = errno;
printf( "lseek64 to %lld failed, %s\n", length - 512, strerror(
errno ) );
goto err;
}
if( write( fd, buf, 512 ) != 512 ){
ret = errno;
printf( "write failed, %s\n", strerror( errno ) );
goto err;
}
err:
close( fd );
if( 0 == ret ){
if( 0 == errno ){
printf( "create file %s with size %d MB successfully\n",
new_file, length_mb );
}
else{
printf( "close file failed, error: %s\n", strerror( errno ) );
unlink( new_file );
}
}
else{
unlink( new_file );
}
return ret;
}
Its aim is to create a expected size file via move the file pointer and
write a sector.
steps:
1. create a ntfs volume under windows xp.
2. boot into suse linux 10.1, with FUSE 2.6.0,
ntfs-3g-0.20070102-BETA<http://www.ntfs-3g.org/ntfs-3g-0.20070102-BETA.tgz>
3. mount the ntfs volume to /mnt/ntfs
4. run "createf /mnt/ntfs/test 1", 'ls -l /mnt/ntfs/test' show its size is
1048576 bytes. It is correct, but command 'df' does not show that volume
space has decreased with 1 mega bytes .
5. boot to windows xp. run 'fsutil file queryallocranges offset=0
length=1048576 f:\test, it shows that only 64K space is allocated at the end
of the file . But the file size still show 1mega bytes and volume does not
show it decrease 1 mega bytes. It's the inconistence
The files created on reiserfs and fat32 volume with this program are all
correct( the full size space are allocated for files), also it works
correctly under windows xp for ntfs volume.
Is this by design?
Please let me know whether you need more information for it.
Regards!
Paul
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
ntfs-3g-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel