linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: flar@pants.nu (Brad Boyer)
To: shalijain@rediffmail.com (shalini jain)
Cc: linuxppc-dev@lists.linuxppc.org (linuxppc-dev@lists.linuxppc.org)
Subject: Re: File size!!!
Date: Sun, 18 Mar 2001 10:08:19 -0800 (PST)	[thread overview]
Message-ID: <20010318180819.42C6C2B54B@marcus.pants.nu> (raw)
In-Reply-To: <20010317205140.31029.qmail@mailweb20.rediffmail.com> from "shalini  jain" at Mar 17, 2001 08:51:40 PM


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/

      reply	other threads:[~2001-03-18 18:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-17 20:51 File size!!! shalini  jain
2001-03-18 18:08 ` Brad Boyer [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=20010318180819.42C6C2B54B@marcus.pants.nu \
    --to=flar@pants.nu \
    --cc=linuxppc-dev@lists.linuxppc.org \
    --cc=shalijain@rediffmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).