shell <-- 부모
-----------------
> test <-- 자식
1. command line에서 test라는 application을 만들라는 명령을 shell에게 전달한다.
2. shell이 fork()를 수행해서 test 라는 프로세스를 생성한다.
- 모든 자료를 부모와 공유한다.
3. test가 자신의 resource를 메모리에 로딩한다.
- test가 execve()를 실행하여 부모로부터 독립한다.
- loader
4. 실행 대기 상태에 있다.
- run_que에서 schedule()의 선택을 기다린다.
5. test 라는 프로세스의 우선 순위가 가장 높은 경우 schedule() 함수에 의해서 선택된 후 실행된다.
6. test라는 프로세스가 실행됨
7. 프로세스 내에 있는 파일 관련 함수가 호출된다.
8. 파일관련 함수는 디바이스 드라이버의 함수를 호출 한다.
위 과정에서 thread로 생성되는 경우는 3.의 과정이 없는 경우라고 생각할 수 있다.
insmod
- 모듈 적재
- 적재
mknod
- 장치 파일
- dentry/inode
소스 분석
task_struct 는 task_union으로 8k byte가 할당된다.
할당된 영역을 stack과 공유
281 struct task_struct {
282 /*
283 * offsets of these are hardcoded elsewhere - touch with care
284 */
285 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
286 unsigned long flags; /* per process flags, defined below */
287 int sigpending;
288 mm_segment_t addr_limit; /* thread address space:
289 0-0xBFFFFFFF for user-thead
290 0-0xFFFFFFFF for kernel-thread
291 */
292 struct exec_domain *exec_domain;
293 volatile long need_resched;
294 unsigned long ptrace;
295
296 int lock_depth; /* Lock depth */
297
298 /*
299 * offset 32 begins here on 32-bit platforms. We keep
300 * all fields in a single cacheline that are needed for
301 * the goodness() loop in schedule().
302 */
303 long counter;
304 long nice;
// counter와 nice로 우선 순위 결정
305 unsigned long policy; // 스케줄링 정책
306 struct mm_struct *mm;
307 int processor;
308 /*
309 * cpus_runnable is ~0 if the process is not running on any
310 * CPU. It's (1 << cpu) if it's running on a CPU. This mask
311 * is updated under the runqueue lock.
312 *
313 * To determine whether a process might run on a CPU, this
314 * mask is AND-ed with cpus_allowed.
315 */
316 unsigned long cpus_runnable, cpus_allowed;
317 /*
318 * (only the 'next' pointer fits into the cacheline, but
319 * that's just fine.)
320 */
321 struct list_head run_list;
322 unsigned long sleep_time;
323
324 struct task_struct *next_task, *prev_task;
325 struct mm_struct *active_mm;
326 struct list_head local_pages;
327 unsigned int allocation_order, nr_local_pages;
328
329 /* task state */
330 struct linux_binfmt *binfmt; // 실행 파일의 바이너리 포맷
331 int exit_code, exit_signal;
332 int pdeath_signal; /* The signal sent when the parent dies */
333 /* ??? */
334 unsigned long personality;
335 int did_exec:1;
336 pid_t pid; // 프로세스 아이디
337 pid_t pgrp;
338 pid_t tty_old_pgrp;
339 pid_t session;
340 pid_t tgid;
341 /* boolean value for session group leader */
342 int leader;
343 /*
344 * pointers to (original) parent process, youngest child, younger sibling,
345 * older sibling, respectively. (p->father can be replaced with
346 * p->p_pptr->pid)
347 */
348 struct task_struct *p_opptr, *p_pptr, *p_cptr, *p_ysptr, *p_osptr;
349 struct list_head thread_group;
350
351 /* PID hash table linkage. */
352 struct task_struct *pidhash_next;
353 struct task_struct **pidhash_pprev;
354
355 wait_queue_head_t wait_chldexit; /* for wait4() */
356 struct completion *vfork_done; /* for vfork() */
357 unsigned long rt_priority;
358 unsigned long it_real_value, it_prof_value, it_virt_value;
359 unsigned long it_real_incr, it_prof_incr, it_virt_incr;
360 struct timer_list real_timer;
361 struct tms times;
362 unsigned long start_time;
363 long per_cpu_utime[NR_CPUS], per_cpu_stime[NR_CPUS];
364 /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
365 unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
366 int swappable:1;
367 /* process credentials */
368 uid_t uid,euid,suid,fsuid;
369 gid_t gid,egid,sgid,fsgid;
370 int ngroups;
371 gid_t groups[NGROUPS];
372 kernel_cap_t cap_effective, cap_inheritable, cap_permitted;
373 int keep_capabilities:1;
374 struct user_struct *user;
375 /* limits */
376 struct rlimit rlim[RLIM_NLIMITS];
377 unsigned short used_math;
378 char comm[16];
379 /* file system info */
380 int link_count, total_link_count;
381 struct tty_struct *tty; /* NULL if no tty */
382 unsigned int locks; /* How many file locks are being held */
383 /* ipc stuff */
384 struct sem_undo *semundo;
385 struct sem_queue *semsleeping;
386 /* CPU-specific state of this task */
387 struct thread_struct thread; // register context 관리를 위한 메모리 공간
388 /* filesystem information */
389 struct fs_struct *fs;
390 /* open file information */
391 struct files_struct *files;
392 /* signal handlers */
393 spinlock_t sigmask_lock; /* Protects signal and blocked */
394 struct signal_struct *sig;
395
396 sigset_t blocked;
397 struct sigpending pending;
398
399 unsigned long sas_ss_sp;
400 size_t sas_ss_size;
401 int (*notifier)(void *priv);
402 void *notifier_data;
403 sigset_t *notifier_mask;
404
405 /* Thread group tracking */
406 u32 parent_exec_id;
407 u32 self_exec_id;
408 /* Protection of (de-)allocation: mm, files, fs, tty */
409 spinlock_t alloc_lock;
410
411 /* journalling filesystem info */
412 void *journal_info;
413 };
파일 시스템
5 struct fs_struct {
6 atomic_t count;
7 rwlock_t lock;
8 int umask;
9 struct dentry * root, * pwd, * altroot;
10 struct vfsmount * rootmnt, * pwdmnt, * altrootmnt;
11 };
절대 경로는 위에 root로부터 시작해서 찾아 갈때 갈 수 있는 경로 이고, pwd는 현재 경로를 나타내므로 상대 경로를 나타낸다.
open file에 대한 information
169 /*
170 * Open file table structure
171 */
172 struct files_struct {
173 atomic_t count;
174 rwlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */
175 int max_fds;
176 int max_fdset;
177 int next_fd;
178 struct file ** fd; /* current fd array */
179 fd_set *close_on_exec;
180 fd_set *open_fds;
181 fd_set close_on_exec_init;
182 fd_set open_fds_init;
183 struct file * fd_array[NR_OPEN_DEFAULT];
184 };
위에서 하나의 struct file **fd는 한개의 open 된 파일의 정보를 가진다.
519 struct file {
520 struct list_head f_list;
521 struct dentry *f_dentry;
522 struct vfsmount *f_vfsmnt;
523 struct file_operations *f_op;
524 atomic_t f_count;
525 unsigned int f_flags;
526 mode_t f_mode;
527 loff_t f_pos;
528 unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;
529 struct fown_struct f_owner;
530 unsigned int f_uid, f_gid;
531 int f_error;
532
533 unsigned long f_version;
534
535 /* needed for tty driver, and maybe others */
536 void *private_data;
537
538 /* preallocated helper kiobuf to speedup O_DIRECT */
539 struct kiobuf *f_iobuf;
540 long f_iobuf_lock;
541 };
위의 f_dentry를 통해서 직접 억세스 할 수 있게 된다. dentry가 필요한 경로에 대한 모든 정보를 가지고 있다.
66 struct dentry {
67 atomic_t d_count;
68 unsigned int d_flags;
69 struct inode * d_inode; /* Where the name belongs to - NULL is negative */
70 struct dentry * d_parent; /* parent directory */
71 struct list_head d_hash; /* lookup hash list */
72 struct list_head d_lru; /* d_count = 0 LRU list */
73 struct list_head d_child; /* child of parent list */
// 현재 디렉토리의 하부 디렉토리를 말한다.
74 struct list_head d_subdirs; /* our children */
// 현재 디렉토리와 같은 등급의 디렉토리이다.
75 struct list_head d_alias; /* inode alias list */
76 int d_mounted;
77 struct qstr d_name;
78 unsigned long d_time; /* used by d_revalidate */
79 struct dentry_operations *d_op;
80 struct super_block * d_sb; /* The root of the dentry tree */
81 unsigned long d_vfs_flags;
82 void * d_fsdata; /* fs-specific data */
83 unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
84 };
파일 operations에 대해서 좀 더 자세히 아래에 보도록 하겠다. 여기 file_operations까지는 실제 하드웨어와 상관없이 연결만 되어 있지만, 여기에 연결된 함수들은 실제 하드웨어와 관련된 일을 하도록 함수를 만든다.
812 /*
813 * NOTE:
814 * read, write, poll, fsync, readv, writev can be called
815 * without the big kernel lock held in all filesystems.
816 */
817 struct file_operations {
818 struct module *owner;
819 loff_t (*llseek) (struct file *, loff_t, int);
820 ssize_t (*read) (struct file *, char *, size_t, loff_t *);
821 ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
822 int (*readdir) (struct file *, void *, filldir_t);
823 unsigned int (*poll) (struct file *, struct poll_table_struct *);
824 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
825 int (*mmap) (struct file *, struct vm_area_struct *);
826 int (*open) (struct inode *, struct file *);
827 int (*flush) (struct file *);
828 int (*release) (struct inode *, struct file *);
829 int (*fsync) (struct file *, struct dentry *, int datasync);
830 int (*fasync) (int, struct file *, int);
831 int (*lock) (struct file *, int, struct file_lock *);
832 ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
833 ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
834 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
835 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
836 };
inode의 구조를 보면,
429 struct inode {
430 struct list_head i_hash;
431 struct list_head i_list;
432 struct list_head i_dentry;
433
434 struct list_head i_dirty_buffers;
435 struct list_head i_dirty_data_buffers;
436
437 unsigned long i_ino;
438 atomic_t i_count;
439 kdev_t i_dev;
--> 440 umode_t i_mode; // 문자 장치 파일임을 여기에 명시함.
441 nlink_t i_nlink;
442 uid_t i_uid;
443 gid_t i_gid;
--> 444 kdev_t i_rdev; // major와 minor 저장으로 chrdev[]와 연관됨
445 loff_t i_size;
446 time_t i_atime;
447 time_t i_mtime;
448 time_t i_ctime;
449 unsigned int i_blkbits;
450 unsigned long i_blksize;
451 unsigned long i_blocks;
452 unsigned long i_version;
453 struct semaphore i_sem;
454 struct semaphore i_zombie;
455 struct inode_operations *i_op;
--> 456 struct file_operations *i_fop; /* former ->i_op->default_file_ops */
// 장치 파일에 관한 operation 함수 여기 포함
457 struct super_block *i_sb;
458 wait_queue_head_t i_wait;
459 struct file_lock *i_flock;
460 struct address_space *i_mapping;
461 struct address_space i_data;
462 struct dquot *i_dquot[MAXQUOTAS];
463 /* These three should probably be a union */
464 struct list_head i_devices;
465 struct pipe_inode_info *i_pipe;
466 struct block_device *i_bdev;
467 struct char_device *i_cdev;
468
469 unsigned long i_dnotify_mask; /* Directory notify events */
470 struct dnotify_struct *i_dnotify; /* for directory notifications */
471
472 unsigned long i_state;
473
474 unsigned int i_flags;
475 unsigned char i_sock;
476
477 atomic_t i_writecount;
478 unsigned int i_attr_flags;
479 __u32 i_generation;
480 union {
481 struct minix_inode_info minix_i;
482 struct ext2_inode_info ext2_i;
483 struct ext3_inode_info ext3_i;
484 struct hpfs_inode_info hpfs_i;
485 struct ntfs_inode_info ntfs_i;
486 struct msdos_inode_info msdos_i;
487 struct umsdos_inode_info umsdos_i;
488 struct iso_inode_info isofs_i;
489 struct nfs_inode_info nfs_i;
490 struct sysv_inode_info sysv_i;
491 struct affs_inode_info affs_i;
492 struct ufs_inode_info ufs_i;
493 struct efs_inode_info efs_i;
494 struct romfs_inode_info romfs_i;
495 struct shmem_inode_info shmem_i;
496 struct coda_inode_info coda_i;
497 struct smb_inode_info smbfs_i;
498 struct hfs_inode_info hfs_i;
499 struct adfs_inode_info adfs_i;
500 struct qnx4_inode_info qnx4_i;
501 struct reiserfs_inode_info reiserfs_i;
502 struct bfs_inode_info bfs_i;
503 struct udf_inode_info udf_i;
504 struct ncp_inode_info ncpfs_i;
505 struct proc_inode_info proc_i;
506 struct socket socket_i;
507 struct usbdev_inode_info usbdev_i;
508 struct jffs2_inode_info jffs2_i;
509 void *generic_ip;
510 } u;
511 };
freetext search 로 vector_swi 찾기(어셈블리어로 되어 있기 때문에 identifier search는 안됨)
Software Interrupt로 넘어 왔을때
121 .align 5
122 ENTRY(vector_swi)
123 save_user_regs
124 zero_fp
1. ---> 125 get_scno
126 arm710_bug_check scno, ip
127
128 #ifdef CONFIG_ALIGNMENT_TRAP
129 ldr ip, __cr_alignment130 ldr ip, [ip]
131 mcr p15, 0, ip, c1, c0 @ update control register
132 #endif
133 enable_irqs ip
134
135 str r4, [sp, #-S_OFF]! @ push fifth arg
136
137 get_current_task tsk
138 ldr ip, [tsk, #TSK_PTRACE] @ check for syscall tracing
2. ---> 139 bic scno, scno, #0xff000000 @ mask off SWI op-code
3. ---> 140 eor scno, scno, #OS_NUMBER << 20 @ check OS number
4. ---> 141 adr tbl, sys_call_table @ load syscall table pointer
142 tst ip, #PT_TRACESYS @ are we tracing syscalls?
143 bne __sys_trace
144
145 adrsvc al, lr, ret_fast_syscall @ return address
146 cmp scno, #NR_syscalls @ check upper syscall limit
5. ---> 147 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
교재 15페이지 슬라이드 18, 1번 과정
205 /*206 * Get the system call number.
207 */
208 .macro get_scno
209 #ifdef CONFIG_ARM_THUMB
210 tst r8, #T_BIT @ this is SPSR from save_user_regs
211 addne scno, r7, #OS_NUMBER << 20 @ put OS number in
---> 212 ldreq scno, [lr, #-4] //ef900005
213
214 #else
215 mask_pc lr, lr
216 ldr scno, [lr, #-4] @ get SWI instruction
217 #endif
218 .endm
sys_call_table
187 ENTRY(sys_call_table)
188 #include "calls.S"
189
190 /*============================================================================
191 * Special system call wrappers
192 */
193 @ r0 = syscall number
194 @ r5 = syscall table
195 .type sys_syscall, #function
196 SYMBOL_NAME(sys_syscall):
197 eor scno, r0, #OS_NUMBER << 20
198 cmp scno, #NR_syscalls @ check range
199 stmleia sp, {r5, r6} @ shuffle args
200 movle r0, r1
201 movle r1, r2
202 movle r2, r3
203 movle r3, r4
204 ldrle pc, [tbl, scno, lsl #2]
205 b sys_ni_syscall
calls.S 파일에 syscall이 모여 있다. 위에서 5번 과정 전에 talble 에 대한 index가 나왔으면 거기에 4를 곱하면 실제 함수 포인터를 구할 수 있다. 왜냐하면 syscalls가 함수 포인터 위치를 담고 있으므로 4 바이트씩의 공간을 잡고 있기 때문이다.
1 /*
2 * linux/arch/arm/lib/calls.h
3 *
4 * Copyright (C) 1995-1998 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This file is included twice in entry-common.S
11 */
12 #ifndef NR_syscalls
13 #define NR_syscalls 256
14 #else
15
16 __syscall_start:
17 /* 0 */ .long SYMBOL_NAME(sys_ni_syscall)
18 .long SYMBOL_NAME(sys_exit)
19 .long SYMBOL_NAME(sys_fork_wrapper)
20 .long SYMBOL_NAME(sys_read)
21 .long SYMBOL_NAME(sys_write)
22 /* 5 */ .long SYMBOL_NAME(sys_open)
23 .long SYMBOL_NAME(sys_close)
24 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_waitpid */
25 .long SYMBOL_NAME(sys_creat)
26 .long SYMBOL_NAME(sys_link)
27 /* 10 */ .long SYMBOL_NAME(sys_unlink)
28 .long SYMBOL_NAME(sys_execve_wrapper)
29 .long SYMBOL_NAME(sys_chdir)
30 .long SYMBOL_NAME(sys_time) /* used by libc4 */
31 .long SYMBOL_NAME(sys_mknod)
32 /* 15 */ .long SYMBOL_NAME(sys_chmod)
33 .long SYMBOL_NAME(sys_lchown16)
34 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_break */
35 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_stat */
36 .long SYMBOL_NAME(sys_lseek)
37 /* 20 */ .long SYMBOL_NAME(sys_getpid)
38 .long SYMBOL_NAME(sys_mount)
39 .long SYMBOL_NAME(sys_oldumount) /* used by libc4 */
40 .long SYMBOL_NAME(sys_setuid16)
41 .long SYMBOL_NAME(sys_getuid16)
42 /* 25 */ .long SYMBOL_NAME(sys_stime)
43 .long SYMBOL_NAME(sys_ptrace)
44 .long SYMBOL_NAME(sys_alarm) /* used by libc4 */
45 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_fstat */
46 .long SYMBOL_NAME(sys_pause)
47 /* 30 */ .long SYMBOL_NAME(sys_utime) /* used by libc4 */
48 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_stty */
49 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_getty */
50 .long SYMBOL_NAME(sys_access)
51 .long SYMBOL_NAME(sys_nice)
52 /* 35 */ .long SYMBOL_NAME(sys_ni_syscall) /* was sys_ftime */
53 .long SYMBOL_NAME(sys_sync)
54 .long SYMBOL_NAME(sys_kill)
55 .long SYMBOL_NAME(sys_rename)
56 .long SYMBOL_NAME(sys_mkdir)
57 /* 40 */ .long SYMBOL_NAME(sys_rmdir)
58 .long SYMBOL_NAME(sys_dup)
59 .long SYMBOL_NAME(sys_pipe)
60 .long SYMBOL_NAME(sys_times)
61 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_prof */
62 /* 45 */ .long SYMBOL_NAME(sys_brk)
63 .long SYMBOL_NAME(sys_setgid16)
64 .long SYMBOL_NAME(sys_getgid16)
65 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_signal */
66 .long SYMBOL_NAME(sys_geteuid16)
67 /* 50 */ .long SYMBOL_NAME(sys_getegid16)
68 .long SYMBOL_NAME(sys_acct)
69 .long SYMBOL_NAME(sys_umount)
70 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_lock */
71 .long SYMBOL_NAME(sys_ioctl)
72 /* 55 */ .long SYMBOL_NAME(sys_fcntl)
73 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_mpx */
74 .long SYMBOL_NAME(sys_setpgid)
75 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_ulimit */
76 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_olduname */ 77 /* 60 */ .long SYMBOL_NAME(sys_umask)
78 .long SYMBOL_NAME(sys_chroot)
79 .long SYMBOL_NAME(sys_ustat)
80 .long SYMBOL_NAME(sys_dup2)
81 .long SYMBOL_NAME(sys_getppid)
82 /* 65 */ .long SYMBOL_NAME(sys_getpgrp)
83 .long SYMBOL_NAME(sys_setsid)
84 .long SYMBOL_NAME(sys_sigaction)
85 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_sgetmask */
86 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_ssetmask */
87 /* 70 */ .long SYMBOL_NAME(sys_setreuid16)
88 .long SYMBOL_NAME(sys_setregid16)
89 .long SYMBOL_NAME(sys_sigsuspend_wrapper)
90 .long SYMBOL_NAME(sys_sigpending)
91 .long SYMBOL_NAME(sys_sethostname)
92 /* 75 */ .long SYMBOL_NAME(sys_setrlimit)
93 .long SYMBOL_NAME(sys_old_getrlimit) /* used by libc4 */
94 .long SYMBOL_NAME(sys_getrusage)
95 .long SYMBOL_NAME(sys_gettimeofday)
96 .long SYMBOL_NAME(sys_settimeofday)
97 /* 80 */ .long SYMBOL_NAME(sys_getgroups16)
98 .long SYMBOL_NAME(sys_setgroups16)
99 .long SYMBOL_NAME(old_select) /* used by libc4 */
100 .long SYMBOL_NAME(sys_symlink)
101 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_lstat */
102 /* 85 */ .long SYMBOL_NAME(sys_readlink)
103 .long SYMBOL_NAME(sys_uselib)
104 .long SYMBOL_NAME(sys_swapon)
105 .long SYMBOL_NAME(sys_reboot)
106 .long SYMBOL_NAME(old_readdir) /* used by libc4 */
107 /* 90 */ .long SYMBOL_NAME(old_mmap) /* used by libc4 */
108 .long SYMBOL_NAME(sys_munmap)
109 .long SYMBOL_NAME(sys_truncate)
110 .long SYMBOL_NAME(sys_ftruncate)
111 .long SYMBOL_NAME(sys_fchmod)
112 /* 95 */ .long SYMBOL_NAME(sys_fchown16)
113 .long SYMBOL_NAME(sys_getpriority)
114 .long SYMBOL_NAME(sys_setpriority)
115 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_profil */
116 .long SYMBOL_NAME(sys_statfs)
117 /* 100 */ .long SYMBOL_NAME(sys_fstatfs)
118 .long SYMBOL_NAME(sys_ni_syscall)
119 .long SYMBOL_NAME(sys_socketcall)
120 .long SYMBOL_NAME(sys_syslog)
121 .long SYMBOL_NAME(sys_setitimer)
122 /* 105 */ .long SYMBOL_NAME(sys_getitimer)
123 .long SYMBOL_NAME(sys_newstat)
124 .long SYMBOL_NAME(sys_newlstat)
125 .long SYMBOL_NAME(sys_newfstat)
126 .long SYMBOL_NAME(sys_ni_syscall) /* was sys_uname */
127 /* 110 */ .long SYMBOL_NAME(sys_ni_syscall) /* was sys_iopl */
128 .long SYMBOL_NAME(sys_vhangup)
129 .long SYMBOL_NAME(sys_ni_syscall)
130 .long SYMBOL_NAME(sys_syscall) /* call a syscall */
131 .long SYMBOL_NAME(sys_wait4)
132 /* 115 */ .long SYMBOL_NAME(sys_swapoff)
133 .long SYMBOL_NAME(sys_sysinfo)
134 .long SYMBOL_NAME(sys_ipc)
135 .long SYMBOL_NAME(sys_fsync)
136 .long SYMBOL_NAME(sys_sigreturn_wrapper)
137 /* 120 */ .long SYMBOL_NAME(sys_clone_wapper)
138 .long SYMBOL_NAME(sys_setdomainname)
139 .long SYMBOL_NAME(sys_newuname)
140 .long SYMBOL_NAME(sys_ni_syscall)
141 .long SYMBOL_NAME(sys_adjtimex)
142 /* 125 */ .long SYMBOL_NAME(sys_mprotect)
143 .long SYMBOL_NAME(sys_sigprocmask)
144 .long SYMBOL_NAME(sys_create_module)
145 .long SYMBOL_NAME(sys_init_module)
146 .long SYMBOL_NAME(sys_delete_module)
147 /* 130 */ .long SYMBOL_NAME(sys_get_kernel_syms)
148 .long SYMBOL_NAME(sys_quotactl)
149 .long SYMBOL_NAME(sys_getpgid)
150 .long SYMBOL_NAME(sys_fchdir)
151 .long SYMBOL_NAME(sys_bdflush)
152 /* 135 */ .long SYMBOL_NAME(sys_sysfs)
153 .long SYMBOL_NAME(sys_personality)
154 .long SYMBOL_NAME(sys_ni_syscall) /* .long _sys_afs_syscall */
155 .long SYMBOL_NAME(sys_setfsuid16)
156 .long SYMBOL_NAME(sys_setfsgid16)
157 /* 140 */ .long SYMBOL_NAME(sys_llseek)
158 .long SYMBOL_NAME(sys_getdents)
159 .long SYMBOL_NAME(sys_select)
160 .long SYMBOL_NAME(sys_flock)
161 .long SYMBOL_NAME(sys_msync)
162 /* 145 */ .long SYMBOL_NAME(sys_readv)
163 .long SYMBOL_NAME(sys_writev)
164 .long SYMBOL_NAME(sys_getsid)
165 .long SYMBOL_NAME(sys_fdatasync)
166 .long SYMBOL_NAME(sys_sysctl)
167 /* 150 */ .long SYMBOL_NAME(sys_mlock)
168 .long SYMBOL_NAME(sys_munlock)
169 .long SYMBOL_NAME(sys_mlockall)
170 .long SYMBOL_NAME(sys_munlockall)
171 .long SYMBOL_NAME(sys_sched_setparam)
172 /* 155 */ .long SYMBOL_NAME(sys_sched_getparam)
173 .long SYMBOL_NAME(sys_sched_setscheduler)
174 .long SYMBOL_NAME(sys_sched_getscheduler)
175 .long SYMBOL_NAME(sys_sched_yield)
176 .long SYMBOL_NAME(sys_sched_get_priority_max)
177 /* 160 */ .long SYMBOL_NAME(sys_sched_get_priority_min)
178 .long SYMBOL_NAME(sys_sched_rr_get_interval)
179 .long SYMBOL_NAME(sys_nanosleep)
180 .long SYMBOL_NAME(sys_arm_mremap)
181 .long SYMBOL_NAME(sys_setresuid16)
182 /* 165 */ .long SYMBOL_NAME(sys_getresuid16)
183 .long SYMBOL_NAME(sys_ni_syscall)
184 .long SYMBOL_NAME(sys_query_module)
185 .long SYMBOL_NAME(sys_poll)
186 .long SYMBOL_NAME(sys_nfsservctl)
187 /* 170 */ .long SYMBOL_NAME(sys_setresgid16)
188 .long SYMBOL_NAME(sys_getresgid16)
189 .long SYMBOL_NAME(sys_prctl)
190 .long SYMBOL_NAME(sys_rt_sigreturn_wrapper)
191 .long SYMBOL_NAME(sys_rt_sigaction)
192 /* 175 */ .long SYMBOL_NAME(sys_rt_sigprocmask)
193 .long SYMBOL_NAME(sys_rt_sigpending)
194 .long SYMBOL_NAME(sys_rt_sigtimedwait)
195 .long SYMBOL_NAME(sys_rt_sigqueueinfo)
196 .long SYMBOL_NAME(sys_rt_sigsuspend_wrapper)
197 /* 180 */ .long SYMBOL_NAME(sys_pread)
198 .long SYMBOL_NAME(sys_pwrite)
199 .long SYMBOL_NAME(sys_chown16)
200 .long SYMBOL_NAME(sys_getcwd)
201 .long SYMBOL_NAME(sys_capget)
202 /* 185 */ .long SYMBOL_NAME(sys_capset)
203 .long SYMBOL_NAME(sys_sigaltstack_wrapper)
204 .long SYMBOL_NAME(sys_sendfile)
205 .long SYMBOL_NAME(sys_ni_syscall)
206 .long SYMBOL_NAME(sys_ni_syscall)
207 /* 190 */ .long SYMBOL_NAME(sys_vfork_wrapper)
208 .long SYMBOL_NAME(sys_getrlimit)
209 .long SYMBOL_NAME(sys_mmap2)
210 .long SYMBOL_NAME(sys_truncate64)
211 .long SYMBOL_NAME(sys_ftruncate64)
212 /* 195 */ .long SYMBOL_NAME(sys_stat64)
213 .long SYMBOL_NAME(sys_lstat64)
214 .long SYMBOL_NAME(sys_fstat64)
215 .long SYMBOL_NAME(sys_lchown)
216 .long SYMBOL_NAME(sys_getuid)
217 /* 200 */ .long SYMBOL_NAME(sys_getgid)
218 .long SYMBOL_NAME(sys_geteuid)
219 .long SYMBOL_NAME(sys_getegid)
220 .long SYMBOL_NAME(sys_setreuid)
221 .long SYMBOL_NAME(sys_setregid)
222 /* 205 */ .long SYMBOL_NAME(sys_getgroups)
223 .long SYMBOL_NAME(sys_setgroups)
224 .long SYMBOL_NAME(sys_fchown)
225 .long SYMBOL_NAME(sys_setresuid)
226 .long SYMBOL_NAME(sys_getresuid)
227 /* 210 */ .long SYMBOL_NAME(sys_setresgid)
228 .long SYMBOL_NAME(sys_getresgid)
229 .long SYMBOL_NAME(sys_chown)
230 .long SYMBOL_NAME(sys_setuid)
231 .long SYMBOL_NAME(sys_setgid)
232 /* 215 */ .long SYMBOL_NAME(sys_setfsuid)
233 .long SYMBOL_NAME(sys_setfsgid)
234 .long SYMBOL_NAME(sys_getdents64)
235 .long SYMBOL_NAME(sys_pivot_root)
236 .long SYMBOL_NAME(sys_mincore)
237 /* 220 */ .long SYMBOL_NAME(sys_madvise)
238 .long SYMBOL_NAME(sys_fcntl64)
239 .long SYMBOL_NAME(sys_ni_syscall) /* TUX */
240 .long SYMBOL_NAME(sys_ni_syscall) /* Security */
241 .long SYMBOL_NAME(sys_gettid)
242 /* 225 */ .long SYMBOL_NAME(sys_readahead)
243 __syscall_end:
244
245 .rept NR_syscalls - (__syscall_end - __syscall_start) / 4
246 .long SYMBOL_NAME(sys_ni_syscall)
247 .endr
248 #endif
sys_open()
775 asmlinkage long sys_open(const char * filename, int flags, int mode)
776 {
777 char * tmp;
778 int fd, error;
779
780 #if BITS_PER_LONG != 32
781 flags |= O_LARGEFILE;
782 #endif
783 tmp = getname(filename);
784 fd = PTR_ERR(tmp);
785 if (!IS_ERR(tmp)) {
786 fd = get_unused_fd();
787 if (fd >= 0) {
788 struct file *f = filp_open(tmp, flags, mode);
789 error = PTR_ERR(f);
790 if (IS_ERR(f))
791 goto out_error;
792 fd_install(fd, f);
793 }
794 out:
795 putname(tmp);
796 }
797 return fd;
798
799 out_error:
800 put_unused_fd(fd);
801 fd = error;
802 goto out;
803 }
받은 트랙백이 없고,
댓글이 없습니다.


글
댓글을 달아 주세요
댓글 RSS 주소 : http://www.cipher.pe.kr/tt/cipher/rss/comment/14댓글 ATOM 주소 : http://www.cipher.pe.kr/tt/cipher/atom/comment/14