File size!!!

2 messages, 2 authors, 2001-03-18 · open the first message on its own page

File size!!!

From: shalini jain <hidden>
Date: 2001-03-17 20:51:40

hello list,

can someone suggest the way to find the file size in ext2fs ? actually, want to find the file size in bytes,i.e, the true file size and not in terms of the blocks allocated to the file.

is there any EOF char in ext2fs files ? if yes. what is it ? is there any other way of knowing the file size than to count  up to EOF ???

thanx,
Shalini

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: File size!!!

From: Brad Boyer <hidden>
Date: 2001-03-18 18:08:19

shalini  jain wrote:
can someone suggest the way to find the file size in ext2fs ? actually, want to find the file size in bytes,i.e, the true file size and not in terms of the blocks allocated to the file.
In the kernel:

inode->i_size

In a regular application ( in C ):

#include <sys/stat.h>
#include <unistd.h>

off_t getfilesize(char *myfile)
{
	struct stat fileinfo;
	int err;

	err = stat(myfile, &fileinfo);
	if(err == -1) {
		/* Do something about the error */
		return 0;
	}
	return fileinfo.st_size;
}
is there any EOF char in ext2fs files ? if yes. what is it ? is there any other way of knowing the file size than to count  up to EOF ???
No.

The file size is kept in filesystem metadata, not in the file.

(Every sane filesystem handles file size this way. Even HFS/HFS+)

	Brad Boyer
	flar@pants.nu

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help