Skip to main content

Know Mounted File System Type getmntent() Usage

I want to know the mounted file system type on my linux box, I got one useful stuff called getmntent(); which returns me the struct mntent, which contains the required information.
check out the usage of getmntent().

First one has to use setmntent();
The setmntent() function opens the file system description file fp and returns a file pointer which can be used by getmntent().
Syntax: FILE *setmntent(const char *filename, const char *type);

Then call for getmntent(),
The getmntent() function reads the next line from the file system description file fp and returns a pointer to a structure containing the broken out fields from a line in the file. The pointer points to a static area of memory which is overwritten by subsequent calls to getmntent().
syntax: struct mntent *getmntent(FILE *fp);
The mntent structure is defined in as follows:

struct mntent {
char *mnt_fsname; /* name of mounted file system */
char *mnt_dir; /* file system path prefix */
char *mnt_type; /* mount type (see mntent.h) */
char *mnt_opts; /* mount options (see mntent.h) */
int mnt_freq; /* dump frequency in days */
int mnt_passno; /* pass number on parallel fsck */
};
/etc/fstab file system description file
/etc/mtab mounted file system description file

Here is simple c program which i tried on linux box running on ARM9 processor.
#include
#include
#include
#include
#include

int main(void)
{
FILE *f = setmntent("/etc/mtab", "r");
struct mntent *m;

while ((m = getmntent(f))) {
struct stat st;
dev_t dev = 0;
if (stat(m->mnt_dir, &st) == 0) {
dev = st.st_dev;
}
printf("%s %s %s 0x%llx\n",
m->mnt_fsname, m->mnt_dir, m->mnt_type, (unsigned long long)dev);
}

endmntent(f);
return 0;
}
compile the program as
$ arm-linux-gcc disk1.c

I have connected two mass storage devices one of type FAt32 and one of type EXT3.

The output I got is
# ./a.out
/dev/ram1 /rdisk0 minix 0x101
none /proc/bus/usb usbfs 0xb
/dev/ram1 /rdisk0 minix 0x101
none /proc/bus/usb usbfs 0xb
/dev/sda4 /mnt/WD_800BEVSExternal_575845373036343130393738_4 vfat 0x804
/dev/sda1 /mnt/WD_800BEVSExternal_575845373036343130393738_1 ext3 0x801
Any suggestions.

Comments

Popular posts from this blog

www.meficai.org ICAI MEF 2008-09 Acknowledgement

www.meficai.org ICAI MEF 2008-09 Acknowledgement Institute of Chartered Accountants of India- ICAI Click here to download your acknowledgement or direct link http://www.meficai.org/mymefstatus.jsp Multipurpose Empanelment Form (MEF) 2008-09 Download Multipurpose Empanelment Form (MEF) for the year 2008-09 meficai, www.meficai.org, mef icai, bessel function, dhaka stock exchange ICAI-Multipurpose Empanelment Form (MEF) 2008-09-MEFICAI. [Last date for submission of applications on the website: 15th September, 2008. Last date for receipt of hard copy of duly signed declaration: 25th September, 2008]

Rajasthan Board 10th Results | rajedubord.nic.in | RBSE

Raj Board of Secondary Education, Rajasthan Results at rajeduboard.nic.in Board of Secondary Education, Rajasthan Ajmer declared result of secondary examination today at 4PM official site is rajedubord.nic.in check Secondary Examination- 2008 Result (To be announced on July 1st, 2008 at 4:00 PM) source http:// rajresults.nic.in / Declared result Praveshika Examination-2008 Result (Announced on June 25, 2008 at 4:00 PM) The history of the Board of Secondary Education Rajasthan (BSER) is a remarkable panorama of progressive record of the futurological vision for developing a dynamic system of various sub-systems of examinations and highlights of the academic excellence of the last four decades. The BSER took rapid strides for promotion and development of Secondary Education in Rajasthan, spread over 3,42,239 sq. km. and in more than 6000 schools located in 32 districts involving 8.5 lakhs students for Secondary and Senior Secondary Examination in the year 2000. At present the Board is

ahsec results 2008 | www.ahsec.nic.in

The official website of assam higher secondary education council Results of Assam is down seems they are uploading results , direct link to check ahsec results 2008 is http://resultsassam.nic.in/index.asp You can find results of AHSEC at the link above. current page The Website www.ahsec.nic.in Designed Developed & Hosted by NIC, Assam State Centre, Guwahati is down for result uploading. keep checking this page, I will update as soon as news comes. All the best to AHSEC - assam higher secondary education council students. Direct links http://assam.nic.in/ www.ahsec.nic.in http://resultsassam.nic.in/