- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试编写一个 getdents() 系统调用来列出调用 getdents() 返回的所有目录条目,但我遇到了一个我似乎无法解决的小问题,不确定这是否是一个C 错误(因为我还在学习它)或调用本身的问题。当我打印每个结构的 d_name 时,我总是缺少目录/文件的第一个字母。
Feb 13 11:39:04 node35 kernel: [ 911.353033] entry: ootkit.c
Feb 13 11:39:04 node35 kernel: [ 911.353035] entry: ootkit.mod.c
Feb 13 11:39:04 node35 kernel: [ 911.353036] entry: ootkit.ko
文件名是rootkit.*
我的代码:
asmlinkage int new_getdents(unsigned int fd, struct linux_dirent64 *dirp, unsigned int count)
{
int nread;
int bpos;
struct linux_dirent64 *d;
int (*orig_func)(unsigned int fd, struct linux_dirent64 *dirp, unsigned int count);
t_syscall_hook *open_hook;
open_hook = find_syscall_hook(__NR_getdents);
orig_func = (void*) open_hook->orig_func;
nread = (*orig_func)(fd, dirp, count);
d = dirp;
for (bpos = 0; bpos < nread;) {
d = (struct linux_dirent64 *) ((char*)dirp + bpos);
printk(KERN_INFO "%s\n", d->d_name);
bpos += d->d_reclen;
}
return nread;
}
最佳答案
我最好的猜测是您混淆了 getdents
系统调用的遗留版本和“64”版本。即使在 64 位系统上,似乎也有一个遗留版本(没有 64)编写了一个缺少 d_type
成员的结构(因此名称的第一个字符会被误解为 d_type
成员,如果您使用结构的现代“64”版本)除了(正确的)getdents64
系统调用。
关于c - getdents() 系统调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21760212/
我正在尝试编写一个 getdents() 系统调用来列出调用 getdents() 返回的所有目录条目,但我遇到了一个我似乎无法解决的小问题,不确定这是否是一个C 错误(因为我还在学习它)或调用本身的
背景是我有一个列出目录条目的现有应用程序; strace 显示它只是调用 getdents 并按照返回的顺序列出它们。我希望它们以与不带参数的 ls 调用相同的顺序显示。是否可以通过某种方式更新目录数
我浏览了 K&R C,我注意到为了读取目录中的条目,他们使用了: while (read(dp->fd, (char *) &dirbuf, sizeof(dirbuf)) == sizeof(dir
我正在开发 Cygwin,它没有实现 getdents ,也不是 getdirentries . 我正在处理的代码依赖于了解读取的字节数,这是这些调用的返回值。我似乎只有readdir . Cygwi
作为练习,我想将一些使用许多系统调用的 C 代码翻译成 Golang。我找到了这个 nice code example在 Unix 和 Linux StackExchange 上: /* * Lis
我是一名优秀的程序员,十分优秀!