1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Convert file size to number of blocks on System V-like machines.
5 Copyright (C) 1990, 1997-1999, 2004-2006, 2009-2011 Free Software
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* Written by Brian L. Matthews, blm@6sceng.UUCP. */
25 #include <sys/types.h>
28 # include <sys/param.h>
31 #if !HAVE_STRUCT_STAT_ST_BLOCKS && !defined _POSIX_SOURCE && defined BSIZE
37 # if defined __DJGPP__
38 typedef long daddr_t; /* for disk address */
41 /* Some SysV's, like Irix, seem to lack this. Hope it's correct. */
42 /* Number of inode pointers per indirect block. */
43 # define NINDIR (BSIZE / sizeof (daddr_t))
46 /* Number of direct block addresses in an inode. */
49 /* Return the number of 512-byte blocks in a file of SIZE bytes. */
52 st_blocks (off_t size)
54 off_t datablks = size / 512 + (size % 512 != 0);
59 indrblks = (datablks - NDIR - 1) / NINDIR + 1;
61 if (datablks > NDIR + NINDIR)
63 indrblks += (datablks - NDIR - NINDIR - 1) / (NINDIR * NINDIR) + 1;
65 if (datablks > NDIR + NINDIR + NINDIR * NINDIR)
70 return datablks + indrblks;
73 /* This declaration is solely to ensure that after preprocessing
74 this file is never empty. */
75 typedef int textutils_fileblocks_unused;