mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Sebastian Claßen" <Sebastian.Classen@freenet-ag.de>
To: linux-kernel@vger.kernel.org
Subject: FIGETBSZ and FIBMAP for directorys
Date: Wed, 15 Jun 2005 09:58:07 +0200	[thread overview]
Message-ID: <1118822287.28239.10.camel@basti79.freenet-ag.de> (raw)

Hi list...

I'm using this little program to find out which blocks are use by a
particular file:
int main(int argc, char **argv) {
        int             fd,
                        i,
                        block,
                        blocksize,
                        bcount;
        struct stat     st;

        assert(argv[1] != NULL);
        assert(fd=open(argv[1], O_RDONLY));
        assert(ioctl(fd, FIGETBSZ, &blocksize) == 0);
        assert(!fstat(fd, &st));
        bcount = (st.st_size + blocksize - 1) / blocksize;
        printf("File: %s Size: %d Blocks: %d Blocksize: %d\n", 
                argv[1], st.st_size, bcount, blocksize);
        for(i=0;i < bcount;i++) {
                block=i;
                if (ioctl(fd, FIBMAP, &block)) {
                        printf("FIBMAP ioctl failed - errno: %s\n",
                                        strerror(errno));
                }
                printf("%3d %10d\n", i, block);
        }
        close(fd);
}


This works fine for regular files, but not for directorys. Both ioctl's,
FIGETBSZ and FIBMAP, are implemented for regular files only. 

Is there a patch to make this FIGETBSZ and FIBMAP work on directorys
too?
Or alternativly, is there a way to find out which blocks are used by a
directory?

Thanks for answers in advance
  Sebastian.



             reply	other threads:[~2005-06-15  7:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-15  7:58 Sebastian Claßen [this message]
2005-06-15 22:46 ` Nathan Scott
2005-06-15 23:15 Nikita Danilov

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=1118822287.28239.10.camel@basti79.freenet-ag.de \
    --to=sebastian.classen@freenet-ag.de \
    --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

all inboxes | Powered by JetHome®