- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to get offset of a file in a raw device
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
Forums
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
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
03-11-2009 01:54 AM
03-11-2009 01:54 AM
How to get offset of a file in a raw device
I'm looking for a C function, to get a file's position (offset) within a raw device.
My program currently searches through the device until it finds a specific string within a known file and returns the file's offset.
This is very inefficient, therefore I was wondering if there is a function to get the position of the file from the filesystem ?
Thank you very much in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2009 02:07 AM
03-11-2009 02:07 AM
Re: How to get offset of a file in a raw device
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2009 02:14 AM
03-11-2009 02:14 AM
Re: How to get offset of a file in a raw device
However just finding the starting block of a file won't necessarily help, as there's nothing to force the file to be contiguous on the disk, so unless you really understand the structure of the VxFS filesystem (and as Dennis pointed out, any underlying volume management software), I'm not sure you're going to be able to easily acheive this. To my knowledge the internal structure of VxFS and LVM/VxVM are *not* in the public domain, and there are no published interfaces to access these from user land.
Can I ask _why_ you want to do this?
HTH
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2009 02:24 AM
03-11-2009 02:24 AM
Re: How to get offset of a file in a raw device
would pstat be aware of anything below VFS level? I wouldn't have expected it to have any knowledge of VxFS or a volume manager?
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2009 02:49 AM
03-11-2009 02:49 AM
Re: How to get offset of a file in a raw device
As Duncan said, it's possible to get the position of the file with fsdb.
My file will never exceed the blocksize of the filesystem, therefore it won't get "splitted".
And because fsdb is able to do it, I thought there might be a function to integrate in my program.
The program is doing several "measurements" with filesystems replicated by XP continous acces. There are some SLA requirements we need to observe and report, therefore I started to write this program, to make things easier.
Because the sVol is read only - I have to access the raw device to locate and analyse my monitored "testfile".
As I said, currently the program reads through the block device until it finds the unique (hopefully unique :-) ) string within the file - upon finding the string I can read everything I want from the file.
Basically all that works fine.
But everytime the binary searches through the device it unnecessarily generates a high i/o load.
So basically I have the possibility to access the filesystem functions on the p-Vol side and transmit the location of the file to the other program running on the s-Vol side. (Upon startup both programs establish a TCP connection, to exchange data)
I've looked into the pstat() documentation and it looks like it provides lots of file properties, but is not able to provide the offset of the underlying raw device.
I'm using vxfs with LVM.
I appreciating your time to help me.
Greetings
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2009 03:11 AM
03-11-2009 03:11 AM
Re: How to get offset of a file in a raw device
I remember we talked in your other post:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1295679
about measuring the time taken to transfer a write from the pvol to the svol using pairsyncwait
are there additional measurements on top of this you need to make? what are they? maybe there's a better way of doing that.
incidentally you mention reading from the block device... I hop you're not doing that at the svol end as you will be using buffer cache - not a good thing when the svol is changing without the host being aware. I'd expect you'd need to use the raw device (which is probably harder but there you go...)
HTH
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2009 06:02 AM
03-11-2009 06:02 AM
Re: How to get offset of a file in a raw device
I'd like to stick on the solution through my own binary, because of personal education ;-)
I'm trying to raise my C skills.
Yes - I was talking about the raw device, sorry I confused it.
Please let me know, if somebody knows a function accessible through C, that does the desired job. But it seems that is not possible.
greetings