カーネルモジュール内のすべてのマウントポイントを取得しようとしています。以下は私が思いついたものです。それはstrcatのためにsegfaultsです。これはマウントポイントを取得する正しい方法ですか?これは使えますか?もしそうなら、私はsegfaultをどのように修正するのですか?もしそうでなければ、Linuxカーネルモジュールでマウントポイントを取得する方法は?カーネルモジュールのすべてのマウントポイントを取得する
私はcycle the whole namespace looking for mountpoint roots that matchを試しましたが、2003年以降、カーネルはそれほど変わっていないので、基本的に役に立たないです。また、get filesystem mount point in kernel moduleを試してみましたが、2012年からもう一度試しました。
static int __init misc_init(void)
{
struct path path;
struct dentry *thedentry;
struct dentry *curdentry;
kern_path("/", LOOKUP_FOLLOW, &path);
thedentry = path.dentry;
list_for_each_entry(curdentry, &thedentry->d_subdirs, d_child)
{
kern_path(strncat("/", curdentry->d_name.name, strlen(curdentry->d_name.name)), LOOKUP_FOLLOW, &path);
if (path_is_mountpoint(&path))
{
printk("%s: is a mountpoint", curdentry->d_name.name);
}
else
printk("%s: is not a mountpoint", curdentry->d_name.name);
}
return 0;
}
'man strncat'を読んだことがありますか?あなたは驚くでしょう。 –
はい私は持っています。 Iveはstrjoin、strlcat、strncat、strcatを試しました。 – testfile
... 'strlen(curdentry-> d_name.name))'は意味がありません – wildplasser