- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to get LVM info from inside a C program?
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
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
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
тАО02-26-2001 03:01 PM
тАО02-26-2001 03:01 PM
How to get LVM info from inside a C program?
I need to get info on LVM configuration from inside a C/C++ program - just basic stuff, a list of volume groups and what disks are in each group, and a list of logical volumes in each group and the size of each if these. I can't use system commands from inside the program as it can cause blocking issues. This info may be available from an ioctl() but I am not sure which command to pass it. I can't find any documentation about this at all.
Does anyone know how I can get this info? Any info or ideas on this would be much appreciated.
Thanks,
Rebecca
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 03:10 PM
тАО02-26-2001 03:10 PM
Re: How to get LVM info from inside a C program?
After that it's called reading the headers from the disk and working out what's going on.
The advantage pstat() has is that you don't need to be root to run it and your program will be release independant.
- Tags:
- pstat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 03:18 PM
тАО02-26-2001 03:18 PM
Re: How to get LVM info from inside a C program?
Also for disks same thing - it doesn't give the name of the disk only the device number and it doesn't specify which volume group (if any) it is in, or any size info.
This is what I still need to find out. As for reading the disk labels is there any standard way of doing this - an ioctl() or other call to retrieve this info.
Thanks alot for your help,
Rebecca
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 03:32 PM
тАО02-26-2001 03:32 PM
Re: How to get LVM info from inside a C program?
If you absolutely must use function calls, you may need to install Veritas VxFS for HP-UX.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 03:38 PM
тАО02-26-2001 03:38 PM
Re: How to get LVM info from inside a C program?
The best thing to do, would be to traverse the /dev directory using fstat(). Then you could match up the lvol name to the major/minor number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 03:45 PM
тАО02-26-2001 03:45 PM
Re: How to get LVM info from inside a C program?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 03:52 PM
тАО02-26-2001 03:52 PM
Re: How to get LVM info from inside a C program?
Therefore I would suggest just running the 'lvm' program attached (for hp-ux 11). Written by a colleague with the source code for lvm!.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 03:55 PM
тАО02-26-2001 03:55 PM
Re: How to get LVM info from inside a C program?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 05:31 PM
тАО02-26-2001 05:31 PM
Re: How to get LVM info from inside a C program?
I ran the executable you sent and it does help a bit - the main problem here is how to do I map the Volume Group ID which looks like this: 565706537 964590021 to either a device number or the volume group name (ie vg00).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 06:19 PM
тАО02-26-2001 06:19 PM
Re: How to get LVM info from inside a C program?
If the vg is on an array for example, it's possible you might import the vg onto multiple systems (at different times) under different names.
None of the lvm structures know the names of anything. The lvol's are all lvol minor number only (which usually ties up with the lvol name, but not always).
The machine id (from uname) is in the output from the 'lvm' command, so at least see the last machine that had the vg.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 06:49 PM
тАО02-26-2001 06:49 PM
Re: How to get LVM info from inside a C program?
I have also done the same on the files under /etc/lvmconf which also give this information but from what I read these files are not updated automatically but only by the user - if the user doesn't do it they won't be updated - is this correct? Is ths the same for the lvmtab file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 10:11 PM
тАО02-26-2001 10:11 PM
Re: How to get LVM info from inside a C program?
lvmtab is a binary file, and therefore working out the file format wouldn't be difficult to achieve. Just dump it out in hex and compare a few machines, it's pretty simple.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 10:28 PM
тАО02-26-2001 10:28 PM
Re: How to get LVM info from inside a C program?
I would also like to get alloc/unalloc MB for the disks and the volume groups. This can be determined from the output of the executable you sent so I guess I can do this the same way - by reading the lvmrec, VGDA, etc from the disk character special file - but I don't know the format of the structures to read this info into. Do you know the structure definitions or can you point me to some documentation on this?