I'm trying to write a block of C code that parses the /etc/fstab file and gives me back the information for each mount. I'm really only interested in three bits of data per mount, the mount point, the filesystem type and the mount options. I have the following code:
Code:
setfsent();
while (fs_tab = getfsent()) {
printf("Mount source: %s\n", fs_tab -> fs_spec);
printf("Mount point: %s\n", fs_tab -> fs_file);
printf("Mount type: %s\n", fs_tab -> fs_type);
printf("Mount options: %s\n", fs_tab -> fs_mntops);
printf("--------------------------\n");
}
endfsent();
When I compile my program and run it. I get a list of every mount point, but the type just shows ?? eg:
Code:
Mount source: /dev/sda3
Mount point: /var
Mount type: ??
Mount options: defaults
--------------------------
Mount source: /dev/sda1
Mount point: none
Mount type: sw
Mount options: sw
--------------------------
Mount source: /dev/hda
Mount point: /media/cdrom0
Mount type: ??
Mount options: user,noauto
--------------------------
The filetypes in this example output are xfs for /var and udf,iso9660 for the cdrom drive. Why can't fstab.h determine the filetype for the mount?
In the documents for fstab.h it says:
char *fs_vfstype
This is the type of the filesystem. Depending on what the underlying kernel understands it can be any string.
So I assume that because the system can mountan xfs filesystem, it must know what that type is. When I run an lsmod I see that there is an xfs module so does that mean that because xfs is not natively compiled into the kernel it cannot display it? If so, is there an alternate gnu libc that can parse the fstab file that would show me the fstype?
Thanks