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.

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);

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.


Popular posts from this blog

dasara marathi message dasara greetings in marathi

Dasara Marathi Greetings-SMS-marathi-Messages-vijaya dasami
marathi greeting cards for vijaya dasami
Happy Vijaya Dashami ! Celebrate the victory of the forces of good over Evil
Dasara is celebrated in Nepal by the name of Dashain. Vijayadashami (Hindi and Marathi: विजयादशमी, Kannada:ವಿಜಯದಶಮಿ)

Marathi Wishes for Dasara..
Apanas ani aplya kutumbiyans Vijayadashami nimmitt hardik shubhechha!

dassera greetings, marathi world, greetings, dassera, marathi greeting MARATHIGREETING.COMSpecial Marathi Greetings from ...Dasera, nljk. New Born, ckGkph pkgwy. Marathi Birthday, okMarathi Diwali ...

मराठी शुभेच्छापत्रे greeting marathi greetings...New Marathi Greeting Cards. Send this Marathi Dipawali Greeting Dasara Greeting Card to your friends · Click to Send this Greeting card to your friends for ...

मराठी शुभेच्छापत्रे - Greetings Cards, Marathi ...
Send free Marathi Greetings, electronic Greetings, m…

Xilinx's Interview Questions

Xilinx is the world's one of largest supplier of programmable logic devices. It has started R & D department in Hyderabad, India. It has broad scope for embedded system programming in device driver in linux.

Before the interview you have to feel the Xilinx form with information containing all academic details, current/previous employer, contacts of employer( to check out info about you), current ctc, expected ctc and expected date of joining, etc.

I appeared two back to back technical interviews.

The first interview was taken by a young man look like just crossed 30's.

He asked me to tell me about myself.

Then he asked my experience.

He checked my expertise in resume.

He asked questions about RTOS, and Linux Device Drivers.
What is RTOS ? Define it.
How a linux device driver works?
How a character driver works?

He looked at my project summaries and started to ask in depth questions about each project.

After that he asked me to write to delete nth node from starting in Singly Linked Li…

Rajasthan Board 10th Results | | RBSE

Raj Board of Secondary Education, Rajasthan Results at rajeduboard.nic.inBoard of Secondary Education, Rajasthan Ajmer declared result of secondary examination today at 4PM official site is

check Secondary Examination- 2008 Result
(To be announced on July 1st, 2008 at 4:00 PM)

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 conducting …