forked from pkumod/gStore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hole.c
46 lines (43 loc) · 1.31 KB
/
hole.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*=============================================================================
# Filename: temp.c
# Author: syzz
# Mail: [email protected]
# Last Modified: 2015-05-12 15:40
# Description:
=============================================================================*/
#include <stdio.h>
int
main(int argc, char* argv[])
{
int i = 0;
char c = 'A';
FILE* fp = fopen("a.dat", "w+b");
fwrite(&c, sizeof(char), 1, fp);
//when moving to tail, always return 0(point to tail whne exceeding)
//when moving to head, -1 when exceeding(point to original)
fseek(fp, 4096 * 10, SEEK_SET);
//file hole, diffrent across platforms
//mv just change index, so not vary, cp may vary(if transfer data, not neglect hole)
//compress/uncompress will change the size with du -h
//du and ll is different: one for block usage(also neglect hole),
//one for actual size(not neglect hole)
//what's more, even after cp or compress/uncompress, there may also be holes.
fwrite(&i, sizeof(int), 1, fp);
fclose(fp);
/*
FILE* fp = fopen("data.dat", "r+");
char c;
while((c = fgetc(fp)) != EOF)
printf("%c", c);
fclose(fp);
printf("\n");
*/
/*
printf("%c%c%c", 0xE6, 0x88, 0x91);
printf("%c%c%c", 0xE7, 0x88, 0xB1);
printf("%c%c%c", 0xE5, 0x90, 0xB4);
printf("%c%c%c", 0xE5, 0x98, 0x89);
printf("%c%c%c\n", 0xE5, 0x8D, 0xBF);
*/
return 0;
}