struct mntent sd/tf卡
来源:互联网 发布:广告联盟评测网源码 编辑:程序博客网 时间:2024/05/03 22:55
在 struct mntent 中的成员与 /etc/fstab 文件中的条目是直接对应的。它的内容如下:
struct mntent {
char *mnt_fsname; /* 挂载的文件系统的名字 */
char *mnt_dir; /* 挂载点 */
char *mnt_type; /* 文件系统类型:ufs、nfs 等 */
char *mnt_opts; /* 选项,以逗号为分隔符 */
int mnt_freq; /* Dump 的频率(以天为单位) */
int mnt_passno; /* fsck检查的次序 */
};
FILE *setmntent(const char *filename, const char *type);
struct mntent *getmntent(FILE *filep);
int addmntent(FILE *filep, const struct mntent *mnt);
int endmntent(FILE *filep);
char *hasmntopt(const struct mntent *mnt, const char *opt);
setmntent() 是打开包含挂载点项目的文件, 其中的 filename 参数是要打开的文件名, type 参数就像 fopen() 的第二个参数, 代表只读、只写, 或读写皆可的存取模式 。返回FILE*。
getmntent() 则是循序读取整个档案,传回指向 static struct mntent 结构的指针,结构中会填入适当的值。
addmntent() 可以在已开启档案的末端加上资讯,它原本是给 mount 使用的。
endmntent() 的功用是关闭打开的文件。这不能只是呼叫 fclose() 而已,因为可能还有其它与FILE * 有关的内部资料结构需要清理。
hasmntopt() 是个比较特殊的函式。它会扫描第一个参数所传入的struct mntent,找出它的挂载选项是否符合第二个引数。假如找到选项就传回符合的子字符串的位址;否则传回NULL。
/etc/fstab、/etc/mtab 和 /proc/mounts 其中任何一个, 都可以在程序中使用 getmntent() 这组函数来读取
eg:
#include <mntent.h>
struct mntent* mnt;
FILE* fp;
fp = setmntent("/dev/mmc/mmcblk0", "r");
if ( !fp )
{
return FALSE;
}
if(mnt=getmntent(fp) )
{
#if 1
printf("woosoori[%s:%d] mnt->mnt_fsname=%s/n",__FUNCTION__,__LINE__, mnt->mnt_fsname);
printf("woosoori[%s:%d] mnt->mnt_dir=%s/n",__FUNCTION__,__LINE__, mnt->mnt_dir);
printf("woosoori[%s:%d]mnt->mnt_type=%s/n",__FUNCTION__,__LINE__,mnt->mnt_type);
printf("woosoori[%s:%d] mnt->mnt_opts=%s/n",__FUNCTION__,__LINE__, mnt->mnt_opts);
printf("woosoori[%s:%d]mnt->mnt_freq=%d/n",__FUNCTION__,__LINE__,mnt->mnt_freq);
printf("woosoori[%s:%d]mnt->mnt_passno=%d/n",__FUNCTION__,__LINE__,mnt->mnt_passno);
#endif
endmntent(fp);
return TRUE;
}
- struct mntent sd/tf卡
- struct mntent
- struct mntent
- 【转】 struct mntent
- mntent
- TF卡和SD卡
- micro SD(TF)卡详解
- micro SD(TF)卡详解
- SD卡和TF卡引脚定义
- TF卡及SD卡接口规范
- TF卡 SD卡接口【转】
- TF卡和SD卡理解
- Micro SD卡(TF卡)spi
- TF卡及SD卡接口规范
- SD卡和TF卡的区别
- SD卡 TF卡 接口引脚定义
- SD卡和TF卡的区别
- TF卡和SD卡的区别
- centos-64整合nginx和tomcat
- Spring中的依赖注入
- Eclipse编码格式修改
- JSP servlet里面使用getServletContext()抛出NullPointer异常的处理
- JS中不为人知的五种声明Number的方式简要概述
- struct mntent sd/tf卡
- configure: error: no acceptable C compiler found in $PATH
- 加快大表关联查询速度
- ForeFront UAG
- DELL Inspiron M4010笔记本拆机除尘图解
- Android.mk语法规范
- 分享WINDOWS服务器安全十种方式
- 引用外部JS,出现乱码的解决办法
- Thread使用