Manipulando o arquivo mtab
Programa para realizar operações no /etc/mtab. O mtab é o arquivo dos file systems
Descrição
Programa para realizar operações no /etc/mtab. O mtab é o arquivo dos file systems
/* Consulta o o mtab do sistema operacional */
/* No mtab estao os file systems jah montado */
#include<stdio.h>
#include<stdlib.h>
#include<mntent.h>
main() {
struct mntent *ptr;
FILE *fp;
ptr=(struct mntent *)malloc(sizeof(struct mntent ));
if(ptr == 0) abort();
fp=setmntent("/etc/mtab","r");
if(fp == NULL){
fprintf(stderr,"Erro de abertura de arquivo");
abort();
}
while((ptr=getmntent(fp))!=NULL) {
printf("%s\t",ptr->mnt_fsname);
printf("%s\t",ptr->mnt_dir);
printf("%s\t",ptr->mnt_type);
printf("%s\n",ptr->mnt_opts);
}
endmntent(fp);
}