- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how can i get size of blcok device file ???
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2012 01:47 AM
11-22-2012 01:47 AM
how can i get size of blcok device file ???
hi.
I want get size of block device file using c program [/dev/vg01/lvol1]
for example. linux
long long buf;
int fd =open("/dev/vg01/lvol1, O_RD_ONLY);
ioctl( fd, BLKGETSIZE64, &buf)
how can i get size of block device file at the hpux???
please help me;;;;
regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2012 02:47 AM - edited 11-22-2012 02:50 AM
11-22-2012 02:47 AM - edited 11-22-2012 02:50 AM
Re: how can I get size of block device file?
Have you tried calling fstat64? Hmm, that seems to return 0.
You may have to parse the output of bdf.
Or use statvfs(2) but that talks about filesystems, not block devices.
This has been asked before here:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2012 04:57 PM
11-22-2012 04:57 PM
Re: how can I get size of block device file?
but. I tried calling fstat64, stat, statvfs ...... return 0
I want to find solution by C program.
nobody answer??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2012 11:20 PM
11-22-2012 11:20 PM
Re: how can I get size of block device file?
>I tried calling fstat64, stat, statvfs ...... return 0
Yes, I tried fstat64. But did you try statvfs on a filesystem mount point?
bdf(1) can figure it out and it did a fstat64 then it sent a message to a socket.
Did you try the perl code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2012 11:29 PM - edited 11-22-2012 11:50 PM
11-22-2012 11:29 PM - edited 11-22-2012 11:50 PM
Re: how can I get size of block device file?
You may have to find the corresponding character device file ("raw" disk/slice/LV device) and query that to find the size.
"man 7 disk" seems to indicate that the DIOC_CAPACITY ioctl might be useful here. It reports the size as a number of DEV_BSIZE blocks. DEV_BSIZE is defined in <sys/param.h>.
DIOC_DESCRIBE might be useful too, if more information than just the size is needed.
Edit:
I think Linus Torvalds once said that he felt the traditional dualism of block vs. character disk devices was more trouble than it's worth, so he planned to minimize its effects in Linux. Things that in traditional Unix systems work only with character devices can be applied directly to the block devices too whenever it does not cause a conflict. And in Linux, you can open a block device with a special O_DIRECT flag and get the "raw" (character) device behaviour. So, in this particular problem, Linux might be the exception, not the rule.