[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Finding size of a raw device
Hi ,
Probably I found the answer to this .
On a filesystem, by doing an lseek the OS can
track the size of the file via the inodes .
Thus, an lseek with SEEK_END would give the
file size , as the inode tables provide the
needed support for the OS .
But since a raw device bound to a file is a
direct interface , there is no way in which
the OS can figure out its limits , and thus
lseek with SEEK_END would yield a zero .
It would be nice if somebody could confirm
the above explanation .
Cheers !
--- Learner <ruxyz@xxxxxxxxx> wrote: > Hi ,
>
> I was trying to find the size of a raw partition
> using the below program , but the output is not
> correct. Can anybody suggest how to rectify this
> program.
>
> Is it that "lseek" should be used only on regular
> files and not special files ?Is there a proc entry
> which reflects the currently bound raw devices ?
>
> I'am aware that "raw -qa" gives the complete list
> of raw devices , but I wanted to know if there is
> any other method to do so .
>
>
> PROGRAM :-
>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <unistd.h>
>
> main()
> {
> int fd ;
> int start, end ;
>
> fd=open( "/dev/raw/raw1", O_RDONLY );
>
> start=lseek( fd, 0, SEEK_SET );
>
> printf("The Start pt size is %d \n", start);
>
> end=lseek( fd, 0, SEEK_END );
>
> printf("The End pt size is %d \n", end);
> }
>
> OUTPUT :-
>
> The Start pt size is 0
> The End pt size is 0
>
>
> Cheers!
>
>
>
________________________________________________________________________
> Yahoo! India Matrimony: Find your partner online.
> http://yahoo.shaadi.com/india-matrimony/
>
> --
> Kernelnewbies: Help each other learn about the Linux
> kernel.
> Archive:
> http://mail.nl.linux.org/kernelnewbies/
> FAQ: http://kernelnewbies.org/faq/
>
________________________________________________________________________
Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/