/*
============================================================================
Name : test.c
Author : blank
Version :
Copyright : Your copyright notice
Description : 程序3-2 创建一个具有空洞的文件
============================================================================
*/
/*
*
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include "ourhdr.h"
char buf1[] = "abcdefghij";
char buf2[] = "ABCDEFGHIJ";
int main(int argc, char *argv[])
{
int fd;
int n;
if ((fd = creat("file.hole", FILE_MODE)) < 0){
err_sys("create file.hole error
");
}
/*
* offset now = 10
*/
if (write(fd, buf1, 10) != 10){
err_sys("write buf1 to file.hole error
");
}
/*
* offset now = 16384
*/
if (lseek(fd, 16384, SEEK_SET) == -1){
err_sys("lseek file.hole error
");
}
/*
* offset now = 16394
*/
if (write(fd, buf2, 10) != 10){
err_sys("write buf2 to file.hole error
");
}
exit(0);
}
