Hi,
The function calculates the last byte in a page OF A PARTICULAR FILE.
static unsigned
ext2_last_byte(struct inode *inode, unsigned long page_nr)
{
unsigned last_byte = inode->i_size;
/* Currently, last_byte = file size */
last_byte -= page_nr << PAGE_CACHE_SHIFT;
/* Currently, last_byte = file size - no of bytes in file BEFORE this
page */
/* implies last_byte = no of bytes in file in this page and any
subsequent pages */
if (last_byte > PAGE_CACHE_SIZE)
last_byte = PAGE_CACHE_SIZE;
/* Simply check if this is NOT the last page, then obviously last byte
of file in THIS page = page size */
return last_byte;
/* Otherwise since this is the last page, leave last_byte as is */
}
Thanks,
Rajat
________________________________
From: [email protected]
[mailto:[email protected]] On Behalf Of nidhi mittal
hada
Sent: Wednesday, November 04, 2009 2:19 PM
To: Kernelnewbies
Subject: doubt abt a function in ext2
/*
* Return the offset into page `page_nr' of the last valid
* byte in that page, plus one.
*/
static unsigned
ext2_last_byte(struct inode *inode, unsigned long page_nr)
{
unsigned last_byte = inode->i_size;
last_byte -= page_nr << PAGE_CACHE_SHIFT;
if (last_byte > PAGE_CACHE_SIZE)
last_byte = PAGE_CACHE_SIZE;
return last_byte;
}
tht's a small function to get last byte of page number page_nr
but it seems to be wrong
as
last byte of page_nr if byte number start with 0 for page_nr 1
last_byte should be = page_nr * (2^12 )
why its been subtracted from total size i_size?????
pl tell me what i am missing ?
Nidhi
--
Thanks & Regards
Nidhi Mittal Hada
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ