커널을 수정해보려고 하는데...[수정]
글쓴이: kurome / 작성시간: 화, 2005/10/25 - 1:45오후
net/socket.c 에 file_operations에 ofd_read 를 추가하고
static struct file_operations socket_file_ops = { llseek: sock_lseek, read: sock_read, write: sock_write, poll: sock_poll, ioctl: sock_ioctl, mmap: sock_mmap, open: sock_no_open, /* special open code to disallow open via /proc */ release: sock_close, fasync: sock_fasync, readv: sock_readv, writev: sock_writev, sendpage: sock_sendpage, ofd_read: sock_ofd_read /* 추가한 부분*/ };
sock_ofd_read 라는 함수를 만들어 넣어본 뒤에
// // 추가한 함수입니다. 내용은 sock_read 와 동일 합니다. // 단지 새로운 syscall를 생성하기 위해서 테스트 하는 // 용도로 만들어 봤습니다. // static ssize_t sock_ofd_read(struct file *file, char *ubuf, size_t size, loff_t *ppos) { struct socket *sock; struct iovec iov; struct msghdr msg; int flags; if (ppos != &file->f_pos) return -ESPIPE; if (size==0) /* Match SYS5 behaviour */ return 0; sock = socki_lookup(file->f_dentry->d_inode); msg.msg_name=NULL; msg.msg_namelen=0; msg.msg_iov=&iov; msg.msg_iovlen=1; msg.msg_control=NULL; msg.msg_controllen=0; iov.iov_base=ubuf; iov.iov_len=size; flags = !(file->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT; return sock_recvmsg(sock, &msg, size, flags); }
위와 같이 코드를 추가하고 난 뒤 컴파일을 하니 에러가 나더군요...
단순히 file_operation 추가로는 안되는 것 같은데
선행 작업을 무엇을 해야하는지...
혹시나 알고계신 분이 있으시면.. 조언좀 부탁 드립니다.
ps. unistd.h 에
#define __NR_ofd_read (__NR_SYSCALL_BASE+250)
를 추가함..
에러 메시지
socket.c:130: unknown field `ofd_read' specified in initializer socket.c:131: warning: initialization from incompatible pointer type make[2]: *** [socket.o] 오류 1 make[2]: 나감 `/XHYPER255/Kernel/2.4.18-rmk7-pxa1-xhyper255/net' 디렉토 make[1]: *** [first_rule] 오류 2 make[1]: 나감 `/XHYPER255/Kernel/2.4.18-rmk7-pxa1-xhyper255/net' 디렉토 make: *** [_dir_net] 오류 2
Forums:
자세한 내용을 써주셔야 합니다. :shock: 최소한 에러 메시지 정도
자세한 내용을 써주셔야 합니다. :shock: 최소한 에러 메시지 정도는 적어주셔야 하고, 수행한 작업 내용을 간단하게 요약해서 적어주시면 더더욱 좋습니다. 커널 버전도 적어주신다면 역시 도움이 될 수 있습니다.
더불어...
에러 메시지나 코드를 올려주실 때 [ code ]나 [ quote ] 태그를 써주시면 더더욱 좋구요~
작업 내용을 적어주신다면, 이번 경우 ofd_read()의 루틴 내용만 생략하고 나머지 수정 사항들을 적어주시면 되지 않을까 싶습니다.
$PWD `date`
file_operations
혹시나 해서 드리는 말씀인데
include/linux/fs.h 에 있는 struct file_operations 의 원형에도 ofd_read 를 추가하셨나요?
Re: file_operations
하지 않았습니다...
학원 프로젝트 때문에 처음 건드려 보는 것이라서
거의 백치 수준입니다.
추가 해야되는 부분인지요?
/////////////////////////////////////////
감사합니다. ^^; 그걸 추가하니 무리없이잘 넘어 가는 군요
감사 드립니다.
댓글 달기