mount 函数

本文转自:http://blog.csdn.net/ypist/article/details/8181766

当我们在Linux系统的板子上挂载U盘时,会出现,原本在windows上显示正常的文件名,在Linux下全部显示为问号?.

如果需要显示出中文,需要使用uft8模式挂载U盘。

 

 解决中文字符显示问号的方法:
  mount /dev/sdb4 /mnt/ho1 -o iocharset=utf8

然而,在程序中,使用mount函数来这样挂载,却出现了问题。

首先,我们看看mount函数的定义:

int  mount(const  char  *source,  const char *target, const char *filesystemtype, unsigned long mountflags, const void *data);
source :设备 /dev/sda等;
target :挂载点/mnt/usb等;
*filesystemtype:"minix","ext2", "msdos", "proc", "nfs", "iso9660" ,“vfat”etc.;
mountflags:MS_MGC_VAL/还有别的参数;
*data:例如:”codepage=936,iocharset=cp936“。

 

其中:

mountflags 经查阅资料有如下选项:

// MS_RELATIME  //(default for Linux >= 2.6.30) 
// MS_STRICTATIME //(default for Linux < 2.6.30) 

// http://harmattan-dev.nokia.com/docs/library/html/manpages/headers/sys/mount.html
public enum MountFlags : ulong
{
    MS_RDONLY = 1,         // Mount read-only.
    MS_NOSUID = 2,         // Ignore suid and sgid bits.
    MS_NODEV = 4,         // Disallow access to device special files.
    MS_NOEXEC = 8,         // Disallow program execution.
    MS_SYNCHRONOUS = 16,    // Writes are synced at once.
    MS_REMOUNT = 32,    // Alter flags of a mounted FS.
    MS_MANDLOCK = 64,    // Allow mandatory locks on an FS.
    S_WRITE = 128,   // Write on file/directory/symlink.
    S_APPEND = 256,   // Append-only file.
    S_IMMUTABLE = 512,   // Immutable file.
    MS_NOATIME = 1024,  // Do not update access times.
    MS_NODIRATIME = 2048,  // Do not update directory access times.
    MS_BIND = 4096,  // Bind directory at different place.
}; // End Enum MountFlags : ulong


 

iocharset=name
Character set to use for converting from Unicode to ASCII. The default is to
do no conversion. Use iocharset=utf8 for UTF8 translations. This requires
CONFIG_NLS_UTF8 to be set in the kernel .config file.

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值