* File size!!!
@ 2001-03-17 20:51 shalini jain
2001-03-18 18:08 ` Brad Boyer
0 siblings, 1 reply; 2+ messages in thread
From: shalini jain @ 2001-03-17 20:51 UTC (permalink / raw)
To: linuxppc-dev@lists.linuxppc.org
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: File size!!!
2001-03-17 20:51 File size!!! shalini jain
@ 2001-03-18 18:08 ` Brad Boyer
0 siblings, 0 replies; 2+ messages in thread
From: Brad Boyer @ 2001-03-18 18:08 UTC (permalink / raw)
To: shalini jain; +Cc: linuxppc-dev@lists.linuxppc.org
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-03-18 18:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-03-17 20:51 File size!!! shalini jain
2001-03-18 18:08 ` Brad Boyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).