From: "Pádraig Brady" <P@draigBrady.com>
To: Jidong Xiao <jidong.xiao@gmail.com>
Cc: Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: Question about the fallocate system call
Date: Thu, 26 Jul 2012 18:02:33 +0100 [thread overview]
Message-ID: <50117829.5040303@draigBrady.com> (raw)
In-Reply-To: <CAG4AFWa5qKzUqmR+3o4Od_jBt0PT-osUPczbh=VhvLh45+E6ng@mail.gmail.com>
On 07/26/2012 03:30 PM, Jidong Xiao wrote:
> 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.
code looks OK,
but you're not checking the return from fallocate().
I'm guessing it's returning -1 with errno = ENOTSUP
cheers,
Pádraig.
prev parent reply other threads:[~2012-07-26 18:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-26 14:30 Question about the fallocate system call Jidong Xiao
2012-07-26 17:02 ` Pádraig Brady [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50117829.5040303@draigBrady.com \
--to=p@draigbrady.com \
--cc=jidong.xiao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox