$ps
: /proc 파일시스템 읽어서 프로세스 정보를 알려주는 커맨드이다. 따라서 /proc위치에서 특정 프로세스의 ID를 감추면 ps에서 해당 프로세스 정보를 볼 수 없다. 즉, 숨겨진 프로세스가 만들어짐
//생성할 디렉터리 이름, 상위 디렉터리
//파일 권한 설정, 파일을 생성할 디렉터리
procfs에서 파일 삭제
데이터 쓰기
: /proc 파일시스템 읽어서 프로세스 정보를 알려주는 커맨드이다. 따라서 /proc위치에서 특정 프로세스의 ID를 감추면 ps에서 해당 프로세스 정보를 볼 수 없다. 즉, 숨겨진 프로세스가 만들어짐
51struct proc_dir_entry { 52 unsigned int low_ino; 53 mode_t mode; 54 nlink_t nlink; 55 uid_t uid; 56 gid_t gid; 57 loff_t size; 58 const struct inode_operations *proc_iops; //proc에 등록된 파일의 inode에 대한 연산 59 /* 60 * NULL ->proc_fops means "PDE is going away RSN" or 61 * "PDE is just created". In either case, e.g. ->read_proc won't be 62 * called because it's too late or too early, respectively. 63 * 64 * If you're allocating ->proc_fops dynamically, save a pointer 65 * somewhere. 66 */ 67 const struct file_operations *proc_fops; //proc에 등록된 file에 대한 연산 68 struct proc_dir_entry *next, *parent, *subdir; 69 void *data; //proc 항목에서 사용할 데이터 70 read_proc_t *read_proc; //proc 항목을 읽을 때 호출되는 함수 포인터 71 write_proc_t *write_proc; //proc 항목에 쓰기를 할 때 호출되는 함수 포인터 72 atomic_t count; /* use count */ 73 int pde_users; /* number of callers into module in progress */ 74 struct completion *pde_unload_completion; 75 struct list_head pde_openers; /* who did ->open, but not ->release */ 76 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */ 77 u8 namelen; 78 char name[];79};
//생성할 디렉터리 이름, 상위 디렉터리
struct proc_dir_entry *proc_mkdir(const char *name, struct proc_dir_entry *parent)
struct proc_dir_entry *aaa_dir;procfs에 파일 생성
struct proc_dir_entry *bbb_dir;
aaa_dir = proc_mkdir("aaa", NULL) // /proc/aaa 생성
bbb_dir = proc_mkdir("bbb",aaa_dir); // /proc/aaa/bbb 생성
//파일 권한 설정, 파일을 생성할 디렉터리
struct proc_dir_entry *creat_proc_entry(const char *name, mode_t mode, struct proc_dir_entry *parent);mode_t => 0600, 0644 같은 포맷
procfs에서 파일 삭제
remove_proc_entry("bbb", aaa_dir);데이터 읽기
typedef int (read_proc_t)
(char *page //전달할 데이터를 저장할 공간
, char **start, //스트림 데이터의 시작 위치
off_t off, //현재 처리중인 파일의 현재 위치
int count, //버퍼의 크기를 바이트 단위로 지정
int *eof, //파일의 끝을 지정
void *data //파일 등록시 지정된 데이터 주소);
데이터 쓰기
typedef int (write_proc_t)(struct file *file, //파일과 관련된 정보를 담고 있는 주소
const char __user *buffer, //사용자 영역의 데이터
unsigned long count, //전달된 데이터의 크기
void *data); //사용자 영역에서 전달된 데이터를 저장할 커널 영역의 주소
'OS이야기' 카테고리의 다른 글
bio (0) | 2012.01.03 |
---|---|
프로세스의 .text, .data, .lib 구하기 (0) | 2012.01.02 |
문자 디바이스 호출과정 (0) | 2011.12.31 |
EXPORT_SYMBOL (1) | 2011.12.24 |
_syscall# (0) | 2011.12.24 |