[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAG4AFWa5qKzUqmR+3o4Od_jBt0PT-osUPczbh=VhvLh45+E6ng@mail.gmail.com>
Date: Thu, 26 Jul 2012 10:30:09 -0400
From: Jidong Xiao <jidong.xiao@...il.com>
To: Kernel development list <linux-kernel@...r.kernel.org>
Subject: Question about the fallocate system call
Hi,
I just have a simple question about fallocate.
I want to test the punch hole function of fallocate(). So I wrote such
a simple program:
yosemite:/mnt # cat test.c
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <stdint.h>
#include <linux/fs.h>
#include <linux/falloc.h>
int main(void)
{
int fd;
fd = open("testfile", O_RDWR);
fallocate(fd,FALLOC_FL_PUNCH_HOLE,0,500*1024*1024);
close(fd);
return 0;
}
I created a file called "testfile" whose size is 1GB, however, when I
run the above program, the size of the testfile simply won't change,
if I use stat command to check the file status, nothing is changed when I
execute the above program. My filesystem is ext4, as I understand,
ideally when I run the above program, the file size should decrease
from 1GB to 512MB, is there anything wrong with the program or I just
understood incorrectly?
Thank you for any inputs/comments.
-Jidong
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists