Write a utility like cp(1) that copies a file containing holes, without writing the bytes of 0 to the output file.
这个功能实现的关键就是不写入读到的 0. 而只是通过 lseek(2) 或类似函数修改 file offset.
原帖由 ivhb 于 2007-9-5 23:59 发表
int
main(void)
{
int c;
while ((c = getchar()) != EOF)
if (c != 0)
putchar(c);
}
./a.out < a > b
这样不可以么?
不能说hole就是一定要lseek过的吧。事实上,lseek跳过1个字节 ...
原帖由 ivhb 于 2007-9-6 00:14 发表
我觉得你想的太复杂了。APUE基本上还是介绍系统接口。而不是告诉你系统的实现细节。
这个问题,不同的文件系统应该是不同的实现。如何能做到?
作业上也没有说什么文件系统吧?
如果刚好有数据也是0且挨着hole呢?
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |