Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么在开发模块时获取apatch中用户输入的参数呢 #10

Open
SoyBeanMilkx opened this issue Oct 10, 2024 · 3 comments
Open

Comments

@SoyBeanMilkx
Copy link

如题

@lzghzr
Copy link
Owner

lzghzr commented Oct 10, 2024

https://github.com/bmax121/KernelPatch/blob/91df9a771b3dad1ef44b4f8401cb461ee7899ac3/kpms/demo-hello/hello.c#L64

这个demo就是如何获取以及使用用户输入的参数。
init是加载时的,ctl0是主动输入的,ctl1之前没有实装,不知道现在能不能用

@SoyBeanMilkx
Copy link
Author

https://github.com/bmax121/KernelPatch/blob/91df9a771b3dad1ef44b4f8401cb461ee7899ac3/kpms/demo-hello/hello.c#L64

这个demo就是如何获取以及使用用户输入的参数。 init是加载时的,ctl0是主动输入的,ctl1之前没有实装,不知道现在能不能用

好的好的,感谢大佬

@SoyBeanMilkx
Copy link
Author

https://github.com/bmax121/KernelPatch/blob/91df9a771b3dad1ef44b4f8401cb461ee7899ac3/kpms/demo-hello/hello.c#L64

这个demo就是如何获取以及使用用户输入的参数。 init是加载时的,ctl0是主动输入的,ctl1之前没有实装,不知道现在能不能用

您好佬,我在使用kmalloc函数时遇到了一些问题(char** paths = kmalloc(num_paths * sizeof(char), GFP_KERNEL);),但是我导入这个头文件时#include <linux/gfp.h>,依然报错,我点进这个头文件看了一下,发现里面的内容都被注释了。
#ifndef __LINUX_GFP_H
#define __LINUX_GFP_H

#include <common.h>

/* Plain integer GFP bitmasks. Do not use this directly. */
// #define __GFP_DMA 0x01u
// #define __GFP_HIGHMEM 0x02u
// #define __GFP_DMA32 0x04u
// #define __GFP_MOVABLE 0x08u
// #define __GFP_RECLAIMABLE 0x10u
// #define __GFP_HIGH 0x20u
// #define __GFP_IO 0x40u
// #define __GFP_FS 0x80u
// #define __GFP_ZERO 0x100u
// #define __GFP_ATOMIC 0x200u
// #define __GFP_DIRECT_RECLAIM 0x400u
// #define __GFP_KSWAPD_RECLAIM 0x800u
// #define __GFP_WRITE 0x1000u
// #define __GFP_NOWARN 0x2000u
// #define __GFP_RETRY_MAYFAIL 0x4000u
// #define __GFP_NOFAIL 0x8000u
// #define __GFP_NORETRY 0x10000u
// #define __GFP_MEMALLOC 0x20000u
// #define __GFP_COMP 0x40000u
// #define __GFP_NOMEMALLOC 0x80000u
// #define __GFP_HARDWALL 0x100000u
// #define __GFP_THISNODE 0x200000u
// #define __GFP_ACCOUNT 0x400000u
// #define __GFP_NOLOCKDEP 0x800000u

// static inline get_gfp_atomic()
// {
// if (kver >= VERSION(3, 18, 0)) return __GFP_HIGH;

// }

// #define __GFP_RECLAIM ((__force gfp_t)(__GFP_DIRECT_RECLAIM | __GFP_KSWAPD_RECLAIM))

// #define GFP_ATOMIC (__GFP_HIGH | __GFP_ATOMIC | __GFP_KSWAPD_RECLAIM)
// #define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS)

// #define GFP_KERNEL_ACCOUNT (GFP_KERNEL | __GFP_ACCOUNT)
// #define GFP_NOWAIT (__GFP_KSWAPD_RECLAIM)
// #define GFP_NOIO (__GFP_RECLAIM)
// #define GFP_NOFS (__GFP_RECLAIM | __GFP_IO)
// #define GFP_USER (__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_HARDWALL)
// #define GFP_DMA __GFP_DMA
// #define GFP_DMA32 __GFP_DMA32
// #define GFP_HIGHUSER (GFP_USER | __GFP_HIGHMEM)
// #define GFP_HIGHUSER_MOVABLE (GFP_HIGHUSER | __GFP_MOVABLE)
// #define GFP_TRANSHUGE_LIGHT ((GFP_HIGHUSER_MOVABLE | __GFP_COMP | __GFP_NOMEMALLOC | __GFP_NOWARN) & ~__GFP_RECLAIM)
// #define GFP_TRANSHUGE (GFP_TRANSHUGE_LIGHT | __GFP_DIRECT_RECLAIM)

/* Convert GFP flags to their corresponding migrate type */
// #define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE | __GFP_MOVABLE)
// #define GFP_MOVABLE_SHIFT 3

#endif

这个该如何解决呢,怎么使用kmalloc函数呀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants