当前位置: 技术问答>linux和unix
mount函数失败!
来源: 互联网 发布时间:2017-03-11
本文导语: 本帖最后由 xianzq888 于 2012-08-25 12:08:09 编辑 例如在shell中: mount /dev/sdd1 /mnt/test (这样子能够成功) 如果在程序中: mount("/dev/sdd1", "/mnt/test", "ext2", 0, ""); 这样总是错误的。 不知道是什么原因! (终于发...
如果在程序中: mount("/dev/sdd1", "/mnt/test", "ext2", 0, ""); 这样总是错误的。
不知道是什么原因!
(终于发出来了,不容易啊!)
|
看看出了什么错误:
The error values given below result from filesystem type independent
errors. Each file-system type may have its own special errors and its own
special behavior. See the kernel source code for details.
EACCES A component of a path was not searchable. (See also
path_resolution(7).) Or, mounting a read-only file system was
attempted without giving the MS_RDONLY flag. Or, the block device
source is located on a file system mounted with the MS_NODEV option.
EBUSY source is already mounted. Or, it cannot be remounted read-only,
because it still holds files open for writing. Or, it cannot be
mounted on target because target is still busy (it is the working
directory of some thread, the mount point of another device, has
open files, etc.).
EFAULT One of the pointer arguments points outside the user address space.
EINVAL source had an invalid superblock. Or, a remount (MS_REMOUNT) was
attempted, but source was not already mounted on target. Or, a move
(MS_MOVE) was attempted, but source was not a mount point, or was
'/'.
ELOOP Too many links encountered during pathname resolution. Or, a move
was attempted, while target is a descendant of source.
EMFILE (In case no block device is required:) Table of dummy devices is
full.
ENAMETOOLONG
A pathname was longer than MAXPATHLEN.
ENODEV filesystemtype not configured in the kernel.
ENOENT A pathname was empty or had a nonexistent component.
ENOMEM The kernel could not allocate a free page to copy filenames or data
into.
ENOTBLK
source is not a block device (and a device was required).
ENOTDIR
target, or a prefix of source, is not a directory.
ENXIO The major number of the block device source is out of range.
EPERM The caller does not have the required privileges.
The error values given below result from filesystem type independent
errors. Each file-system type may have its own special errors and its own
special behavior. See the kernel source code for details.
EACCES A component of a path was not searchable. (See also
path_resolution(7).) Or, mounting a read-only file system was
attempted without giving the MS_RDONLY flag. Or, the block device
source is located on a file system mounted with the MS_NODEV option.
EBUSY source is already mounted. Or, it cannot be remounted read-only,
because it still holds files open for writing. Or, it cannot be
mounted on target because target is still busy (it is the working
directory of some thread, the mount point of another device, has
open files, etc.).
EFAULT One of the pointer arguments points outside the user address space.
EINVAL source had an invalid superblock. Or, a remount (MS_REMOUNT) was
attempted, but source was not already mounted on target. Or, a move
(MS_MOVE) was attempted, but source was not a mount point, or was
'/'.
ELOOP Too many links encountered during pathname resolution. Or, a move
was attempted, while target is a descendant of source.
EMFILE (In case no block device is required:) Table of dummy devices is
full.
ENAMETOOLONG
A pathname was longer than MAXPATHLEN.
ENODEV filesystemtype not configured in the kernel.
ENOENT A pathname was empty or had a nonexistent component.
ENOMEM The kernel could not allocate a free page to copy filenames or data
into.
ENOTBLK
source is not a block device (and a device was required).
ENOTDIR
target, or a prefix of source, is not a directory.
ENXIO The major number of the block device source is out of range.
EPERM The caller does not have the required privileges.
|
if(mount("/dev/sdd1", "/mnt/test", "ext2", 0, "")