SYS_mount问题 [英] Problem with SYS_mount

查看:110
本文介绍了SYS_mount问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我需要挂载一个环回文件系统。我正在使用SYS_mount,但是

总是因ENOTDIR而失败。我做傻事吗?这是

违规行:


if(syscall(SYS_mount,

" / home / sam / mnt /"," /home/sam/myfile.img"," -o loop"))

perror(Mount failure /);

谢谢。

Hello,

I need to mount a loopback file system. I''m using SYS_mount, but it
always fails with ENOTDIR. Am I doing something silly? Here''s the
offending line:

if(syscall(SYS_mount,
"/home/sam/mnt/", "/home/sam/myfile.img", "-o loop" ))
perror("Mount failure/ ");

Thanks.

推荐答案

2008年5月5日21:14,Sam Joseph写道:
On 5 May 2008 at 21:14, Sam Joseph wrote:

我需要挂载一个环回文件系统。我正在使用SYS_mount,但是

总是因ENOTDIR而失败。我做傻事吗?这是

违规行:


if(syscall(SYS_mount,

" / home / sam / mnt /"," /home/sam/myfile.img"," -o loop"))

perror(" Mount failure /");
I need to mount a loopback file system. I''m using SYS_mount, but it
always fails with ENOTDIR. Am I doing something silly? Here''s the
offending line:

if(syscall(SYS_mount,
"/home/sam/mnt/", "/home/sam/myfile.img", "-o loop" ))
perror("Mount failure/ ");



您的代码和方法存在很多问题,很难知道从哪里开始!

知道从哪里开始!


首先,系统调用的原型是

asmlinkage long sys_mount(char __user * dev_name,char __user * dir_name,

char __user *类型,unsigned long flags,void __user * data);


所以你的代码前两个参数的方法是错误的,而

最后一个缺少两个参数。不幸的是,第三个参数是非常天真的:虽然mount(8)命令很乐意接受选项

,如-o loop,安装系统打电话不是。


但你根本不应该使用挂载系统调用!除了执行

系统调用之外,mount

程序还做了一些其他相当复杂的工作,你需要手动重新完成所有这些操作。何必?只需

运行mount(8)。


如果你真的想以编程方式工作,你可以打开其中一个循环

设备,对它执行ioctl(请求LOOP_SET_FD和额外的参数

" /home/sam/myfile.img"),然后使用mount(2)。

There are so many problems with your code and approach that it''s hard to
know where to begin!

First of all, the prototype for the system call is
asmlinkage long sys_mount(char __user *dev_name, char __user* dir_name,
char __user *type, unsigned long flags, void __user *data);

So your code has the first two arguments the wrong way round, and the
last two arguments are missing. The third argument is, unfortunately,
much too naive: while the mount(8) command is happy to accept options
like "-o loop", the mount system call isn''t.

But you shouldn''t be using the mount system call at all! The mount
program does some other fairly complicated work besides executing a
system call, and you''d need to re-do all that by hand. Why bother? Just
run mount(8).

If you really want to work programatically, you can open one of the loop
devices, perform an ioctl on it (request LOOP_SET_FD with extra argument
"/home/sam/myfile.img"), then use mount(2).


Antoninus Twink写道:
Antoninus Twink wrote:

2008年5月5日21:14,Sam Joseph写道:
On 5 May 2008 at 21:14, Sam Joseph wrote:

>我需要挂载一个环回文件系统。我正在使用SYS_mount,但它总是因ENOTDIR而失败。我做傻事吗?这是
违规行:

if(系统调用(SYS_mount,
" / home / sam / mnt /"," / home / sam / myfile .img"," -o loop"))
perror(Mount failure /);
>I need to mount a loopback file system. I''m using SYS_mount, but it
always fails with ENOTDIR. Am I doing something silly? Here''s the
offending line:

if(syscall(SYS_mount,
"/home/sam/mnt/", "/home/sam/myfile.img", "-o loop" ))
perror("Mount failure/ ");



您的代码和方法存在很多问题,因此很难知道从哪里开始!


首先,系统调用的原型是

asmlinkage long sys_mount(char __user * dev_name,char __user * dir_name,

char __user * type,unsigned long flags,void __user * data);

[...]


There are so many problems with your code and approach that it''s hard to
know where to begin!

First of all, the prototype for the system call is
asmlinkage long sys_mount(char __user *dev_name, char __user* dir_name,
char __user *type, unsigned long flags, void __user *data);
[...]



Drivel。废话。 Idiocy。


到OP:你的问题不是关于C语言,

但关于系统界面提供的(似乎)一些

Unix或POSIX的味道。有关如何获得某些内容以及必要的前提条件的详细信息

和故障模式都是特定于系统的,而不是

语言你解决它。所以寻找一个论坛,你系统上的

专家会在那里闲逛,并尝试在那里询问。


在这里,正如你所见,你' '很可能会变得混乱,

胡说八道,白痴。


-
Er ********* @ sun.com


2008年5月5日21日:47,Eric Sosman写道:
On 5 May 2008 at 21:47, Eric Sosman wrote:

Antoninus Twink写道:
Antoninus Twink wrote:

>首先,系统调用的原型是
asmlinkage long sys_mount(char __user * dev_name,char __user * dir_name,
char __user * type,unsigned long flags,void __user * data);
[.. 。]
>First of all, the prototype for the system call is
asmlinkage long sys_mount(char __user *dev_name, char __user* dir_name,
char __user *type, unsigned long flags, void __user *data);
[...]



Drivel。废话。白痴。


Drivel. Nonsense. Idiocy.



你到底在说什么?如果(很可能)使用Linux,OP是

,他可以通过检查来检查自己。
/usr/src/linux/include/linux/syscalls.h

What on earth are you talking about? If (as is very likely) the OP is
using Linux, he can check for himself by examining
/usr/src/linux/include/linux/syscalls.h


这篇关于SYS_mount问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆