sstea備忘録

日々のPCライフのメモ、備忘録、及びそれに類推する何か。
記載内容に間違い等を発見された場合はコッソリ教えてください... → sstea<a>aol.jp (<a> を @ に変えてください)


プログラム

演算子/errno/シグナル/システムコール 一覧表

プログラム、Linux 関連の各種テーブル早見表。

Linux カーネルのソースコードは↓下記サイトで確認可能。
  https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/

  https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/

表の作成は↓下記サイトにお世話になりました。
http://styleme.jp/tool/xls2html/

◆演算順序(C言語)

優先度 演算子 説明 評価順序
1 ( ) 括弧
[ ] 配列要素
. メンバ参照演算子
-> アロー演算子
2 & アドレス演算子
* 間接演算子
~ ビット反転
! 論理否定
+ プラス符号
- マイナス符号
++ インクリメント
-- デクリメント
sizeof サイズ
(cast) キャスト
3 * 乗算
/ 除算
% 剰余
4 + 加算
- 減算
5 << 左シフト
>> 右シフト
6 < より小さい
<= 以下
> より大きい
>= 以上
7 == 等しい
!= 等しくない
8 & ビット論理積
9 ^ ビット排他的論理和
10 | ビット論理和
11 && 論理積
12 || 論理和
13 ? : 三項演算子
14 = 代入演算子
*=
/=
%=
+=
-=
<<=
>>=
^=
&=
|=
15 , コンマ演算子

◆Linux errno
linux 3.19.3 の下記ファイルを参照し、作成。
- include/uapi/asm-generic/errno-base.h
- include/uapi/asm-generic/errno.h
- include/linux/errno.h

エラー番号 マクロ
コメント
1 EPERM Operation not permitted
2 ENOENT No such file or directory
3 ESRCH No such process
4 EINTR Interrupted system call
5 EIO I/O error
6 ENXIO No such device or address
7 E2BIG Argument list too long
8 ENOEXEC Exec format error
9 EBADF Bad file number
10 ECHILD No child processes
11 EAGAIN Try again
12 ENOMEM Out of memory
13 EACCES Permission denied
14 EFAULT Bad address
15 ENOTBLK Block device required
16 EBUSY Device or resource busy
17 EEXIST File exists
18 EXDEV Cross-device link
19 ENODEV No such device
20 ENOTDIR Not a directory
21 EISDIR Is a directory
22 EINVAL Invalid argument
23 ENFILE File table overflow
24 EMFILE Too many open files
25 ENOTTY Not a typewriter
26 ETXTBSY Text file busy
27 EFBIG File too large
28 ENOSPC No space left on device
29 ESPIPE Illegal seek
30 EROFS Read-only file system
31 EMLINK Too many links
32 EPIPE Broken pipe
33 EDOM Math argument out of domain of func
34 ERANGE Math result not representable
35 EDEADLK Resource deadlock would occur
36 ENAMETOOLONG File name too long
37 ENOLCK No record locks available
38 ENOSYS Function not implemented
39 ENOTEMPTY Directory not empty
40 ELOOP Too many symbolic links encountered
EAGAIN(11) EWOULDBLOCK Operation would block
42 ENOMSG No message of desired type
43 EIDRM Identifier removed
44 ECHRNG Channel number out of range
45 EL2NSYNC Level 2 not synchronized
46 EL3HLT Level 3 halted
47 EL3RST Level 3 reset
48 ELNRNG Link number out of range
49 EUNATCH Protocol driver not attached
50 ENOCSI No CSI structure available
51 EL2HLT Level 2 halted
52 EBADE Invalid exchange
53 EBADR Invalid request descriptor
54 EXFULL Exchange full
55 ENOANO No anode
56 EBADRQC Invalid request code
57 EBADSLT Invalid slot
EDEADLK(35) EDEADLOCK
59 EBFONT Bad font file format
60 ENOSTR Device not a stream
61 ENODATA No data available
62 ETIME Timer expired
63 ENOSR Out of streams resources
64 ENONET Machine is not on the network
65 ENOPKG Package not installed
66 EREMOTE Object is remote
67 ENOLINK Link has been severed
68 EADV Advertise error
69 ESRMNT Srmount error
70 ECOMM Communication error on send
71 EPROTO Protocol error
72 EMULTIHOP Multihop attempted
73 EDOTDOT RFS specific error
74 EBADMSG Not a data message
75 EOVERFLOW Value too large for defined data type
76 ENOTUNIQ Name not unique on network
77 EBADFD File descriptor in bad state
78 EREMCHG Remote address changed
79 ELIBACC Can not access a needed shared library
80 ELIBBAD Accessing a corrupted shared library
81 ELIBSCN .lib section in a.out corrupted
82 ELIBMAX Attempting to link in too many shared libraries
83 ELIBEXEC Cannot exec a shared library directly
84 EILSEQ Illegal byte sequence
85 ERESTART Interrupted system call should be restarted
86 ESTRPIPE Streams pipe error
87 EUSERS Too many users
88 ENOTSOCK Socket operation on non-socket
89 EDESTADDRREQ Destination address required
90 EMSGSIZE Message too long
91 EPROTOTYPE Protocol wrong type for socket
92 ENOPROTOOPT Protocol not available
93 EPROTONOSUPPORT Protocol not supported
94 ESOCKTNOSUPPORT Socket type not supported
95 EOPNOTSUPP Operation not supported on transport endpoint
96 EPFNOSUPPORT Protocol family not supported
97 EAFNOSUPPORT Address family not supported by protocol
98 EADDRINUSE Address already in use
99 EADDRNOTAVAIL Cannot assign requested address
100 ENETDOWN Network is down
101 ENETUNREACH Network is unreachable
102 ENETRESET Network dropped connection because of reset
103 ECONNABORTED Software caused connection abort
104 ECONNRESET Connection reset by peer
105 ENOBUFS No buffer space available
106 EISCONN Transport endpoint is already connected
107 ENOTCONN Transport endpoint is not connected
108 ESHUTDOWN Cannot send after transport endpoint shutdown
109 ETOOMANYREFS Too many references: cannot splice
110 ETIMEDOUT Connection timed out
111 ECONNREFUSED Connection refused
112 EHOSTDOWN Host is down
113 EHOSTUNREACH No route to host
114 EALREADY Operation already in progress
115 EINPROGRESS Operation now in progress
116 ESTALE Stale file handle
117 EUCLEAN Structure needs cleaning
118 ENOTNAM Not a XENIX named type file
119 ENAVAIL No XENIX semaphores available
120 EISNAM Is a named type file
121 EREMOTEIO Remote I/O error
122 EDQUOT Quota exceeded
123 ENOMEDIUM No medium found
124 EMEDIUMTYPE Wrong medium type
125 ECANCELED Operation Canceled
126 ENOKEY Required key not available
127 EKEYEXPIRED Key has expired
128 EKEYREVOKED Key has been revoked
129 EKEYREJECTED Key was rejected by service
130 EOWNERDEAD Owner died
131 ENOTRECOVERABLE State not recoverable
132 ERFKILL Operation not possible due to RF-kill
133 EHWPOISON Memory page has hardware error
512 ERESTARTSYS
513 ERESTARTNOINTR
514 ERESTARTNOHAND restart if no handler..
515 ENOIOCTLCMD No ioctl command
516 ERESTART_RESTARTBLOCK restart by calling sys_restart_syscall
517 EPROBE_DEFER Driver requests probe retry
518 EOPENSTALE open found a stale dentry
519
-

520
-

521 EBADHANDLE Illegal NFS file handle
522 ENOTSYNC Update synchronization mismatch
523 EBADCOOKIE Cookie is stale
524 ENOTSUPP Operation is not supported
525 ETOOSMALL Buffer or request is too small
526 ESERVERFAULT An untranslatable error occurred
527 EBADTYPE Type not supported by server
528 EJUKEBOX Request initiated, but will not complete before timeout
529 EIOCBQUEUED iocb queued, will get completion event


◆シグナル
linux 3.19.3 の下記ファイルを参照し、作成。
- include/uapi/asm-generic/signal.h

シグナル番号 マクロ 備考
1 SIGHUP
2 SIGINT
3 SIGQUIT
4 SIGILL
5 SIGTRAP
6 SIGABRT / SIGIOT
7 SIGBUS
8 SIGFPE
9 SIGKILL マスク不可
10 SIGUSR1
11 SIGSEGV
12 SIGUSR2
13 SIGPIPE
14 SIGALRM
15 SIGTERM
16 SIGSTKFLT
17 SIGCHLD
18 SIGCONT
19 SIGSTOP マスク不可
20 SIGTSTP
21 SIGTTIN
22 SIGTTOU
23 SIGURG
24 SIGXCPU
25 SIGXFSZ
26 SIGVTALRM
27 SIGPROF
28 SIGWINCH
29 SIGIO /*SIGLOST*/
SIGIO(29) SIGPOLL
30 SIGPWR
31 SIGSYS / SIGUNUSED

◆Linux システムコール
linux 3.19.3 の下記ファイルを参照し作成。
- arch/arm/include/uapi/asm/unistd.h

システムコール番号 シンボル
コメント
0 restart_syscall
1 exit
2 fork
3 read
4 write
5 open
6 close
7 - 7 was sys_waitpid
8 creat
9 link
10 unlink
11 execve
12 chdir
13 time
14 mknod
15 chmod
16 lchown
17 - 17 was sys_break
18 - 18 was sys_stat
19 lseek
20 getpid
21 mount
22 umount
23 setuid
24 getuid
25 stime
26 ptrace
27 alarm
28 - 28 was sys_fstat
29 pause
30 utime
31 - 31 was sys_stty
32 - 32 was sys_gtty
33 access
34 nice
35 - 35 was sys_ftime
36 sync
37 kill
38 rename
39 mkdir
40 rmdir
41 dup
42 pipe
43 times
44 - 44 was sys_prof
45 brk
46 setgid
47 getgid
48 - 48 was sys_signal
49 geteuid
50 getegid
51 acct
52 umount2
53 - 53 was sys_lock
54 ioctl
55 fcntl
56 - 56 was sys_mpx
57 setpgid
58 - 58 was sys_ulimit
59 - 59 was sys_olduname
60 umask
61 chroot
62 ustat
63 dup2
64 getppid
65 getpgrp
66 setsid
67 sigaction
68 - 68 was sys_sgetmask
69 - 69 was sys_ssetmask
70 setreuid
71 setregid
72 sigsuspend
73 sigpending
74 sethostname
75 setrlimit
76 getrlimit Back compat 2GB limited rlimit
77 getrusage
78 gettimeofday
79 settimeofday
80 getgroups
81 setgroups
82 select
83 symlink
84 - 84 was sys_lstat
85 readlink
86 uselib
87 swapon
88 reboot
89 readdir
90 mmap
91 munmap
92 truncate
93 ftruncate
94 fchmod
95 fchown
96 getpriority
97 setpriority
98 - 98 was sys_profil
99 statfs
100 fstatfs
101 - 101 was sys_ioperm
102 socketcall
103 syslog
104 setitimer
105 getitimer
106 stat
107 lstat
108 fstat
109 - 109 was sys_uname
110 - 110 was sys_iopl
111 vhangup
112 - 112 was sys_idle
113 syscall syscall to call a syscall!
114 wait4
115 swapoff
116 sysinfo
117 ipc
118 fsync
119 sigreturn
120 clone
121 setdomainname
122 uname
123 - 123 was sys_modify_ldt
124 adjtimex
125 mprotect
126 sigprocmask
127 - 127 was sys_create_module
128 init_module
129 delete_module
130 - 130 was sys_get_kernel_syms
131 quotactl
132 getpgid
133 fchdir
134 bdflush
135 sysfs
136 personality
137 - 137 was sys_afs_syscall
138 setfsuid
139 setfsgid
140 _llseek
141 getdents
142 _newselect
143 flock
144 msync
145 readv
146 writev
147 getsid
148 fdatasync
149 _sysctl
150 mlock
151 munlock
152 mlockall
153 munlockall
154 sched_setparam
155 sched_getparam
156 sched_setscheduler
157 sched_getscheduler
158 sched_yield
159 sched_get_priority_max
160 sched_get_priority_min
161 sched_rr_get_interval
162 nanosleep
163 mremap
164 setresuid
165 getresuid
166 - 166 was sys_vm86
167 - 167 was sys_query_module
168 poll
169 nfsservctl
170 setresgid
171 getresgid
172 prctl
173 rt_sigreturn
174 rt_sigaction
175 rt_sigprocmask
176 rt_sigpending
177 rt_sigtimedwait
178 rt_sigqueueinfo
179 rt_sigsuspend
180 pread64
181 pwrite64
182 chown
183 getcwd
184 capget
185 capset
186 sigaltstack
187 sendfile
188 - 188 reserved
189 - 189 reserved
190 vfork
191 ugetrlimit SuS compliant getrlimit
192 mmap2
193 truncate64
194 ftruncate64
195 stat64
196 lstat64
197 fstat64
198 lchown32
199 getuid32
200 getgid32
201 geteuid32
202 getegid32
203 setreuid32
204 setregid32
205 getgroups32
206 setgroups32
207 fchown32
208 setresuid32
209 getresuid32
210 setresgid32
211 getresgid32
212 chown32
213 setuid32
214 setgid32
215 setfsuid32
216 setfsgid32
217 getdents64
218 pivot_root
219 mincore
220 madvise
221 fcntl64
222 - 222 for tux
223 - 223 is unused
224 gettid
225 readahead
226 setxattr
227 lsetxattr
228 fsetxattr
229 getxattr
230 lgetxattr
231 fgetxattr
232 listxattr
233 llistxattr
234 flistxattr
235 removexattr
236 lremovexattr
237 fremovexattr
238 tkill
239 sendfile64
240 futex
241 sched_setaffinity
242 sched_getaffinity
243 io_setup
244 io_destroy
245 io_getevents
246 io_submit
247 io_cancel
248 exit_group
249 lookup_dcookie
250 epoll_create
251 epoll_ctl
252 epoll_wait
253 remap_file_pages
254 - 254 for set_thread_area
255 - 255 for get_thread_area
256 set_tid_address
257 timer_create
258 timer_settime
259 timer_gettime
260 timer_getoverrun
261 timer_delete
262 clock_settime
263 clock_gettime
264 clock_getres
265 clock_nanosleep
266 statfs64
267 fstatfs64
268 tgkill
269 utimes
270 arm_fadvise64_64
271 pciconfig_iobase
272 pciconfig_read
273 pciconfig_write
274 mq_open
275 mq_unlink
276 mq_timedsend
277 mq_timedreceive
278 mq_notify
279 mq_getsetattr
280 waitid
281 socket
282 bind
283 connect
284 listen
285 accept
286 getsockname
287 getpeername
288 socketpair
289 send
290 sendto
291 recv
292 recvfrom
293 shutdown
294 setsockopt
295 getsockopt
296 sendmsg
297 recvmsg
298 semop
299 semget
300 semctl
301 msgsnd
302 msgrcv
303 msgget
304 msgctl
305 shmat
306 shmdt
307 shmget
308 shmctl
309 add_key
310 request_key
311 keyctl
312 semtimedop
313 vserver
314 ioprio_set
315 ioprio_get
316 inotify_init
317 inotify_add_watch
318 inotify_rm_watch
319 mbind
320 get_mempolicy
321 set_mempolicy
322 openat
323 mkdirat
324 mknodat
325 fchownat
326 futimesat
327 fstatat64
328 unlinkat
329 renameat
330 linkat
331 symlinkat
332 readlinkat
333 fchmodat
334 faccessat
335 pselect6
336 ppoll
337 unshare
338 set_robust_list
339 get_robust_list
340 splice
341 arm_sync_file_range sync_file_range2
342 tee
343 vmsplice
344 move_pages
345 getcpu
346 epoll_pwait
347 kexec_load
348 utimensat
349 signalfd
350 timerfd_create
351 eventfd
352 fallocate
353 timerfd_settime
354 timerfd_gettime
355 signalfd4
356 eventfd2
357 epoll_create1
358 dup3
359 pipe2
360 inotify_init1
361 preadv
362 pwritev
363 rt_tgsigqueueinfo
364 perf_event_open
365 recvmmsg
366 accept4
367 fanotify_init
368 fanotify_mark
369 prlimit64
370 name_to_handle_at
371 open_by_handle_at
372 clock_adjtime
373 syncfs
374 sendmmsg
375 setns
376 process_vm_readv
377 process_vm_writev
378 kcmp
379 finit_module
380 sched_setattr
381 sched_getattr
382 renameat2
383 seccomp
384 getrandom
385 memfd_create
386 bpf
387 execveat

シェルスクリプト/Makefile/LKM 等サンプル

各種プログラム、Makefile サンプル。

◆シェルサンプル
shell/test.sh
#!/bin/bash

# ./test.sh 1 "2 3" 4

TMPFILE=/tmp/test

init() {
        if [ -f ${TMPFILE} ]; then
                rm -f ${TMPFILE}
        elif [ -e ${TMPFILE} ]; then
                exit 1
        fi

        touch ${TMPFILE}
        if [ $? -ne 0 ]; then
                exit 1
        fi
}

main() {
        local arg
        local i=0

        for arg in "$@"; do
                echo ${arg} >> ${TMPFILE}
                list[${i}]=${arg}
                i=$((${i} + 1))
        done

        i=0
        while [ ${i} -lt ${#list[@]} ]; do
                echo ${list[${i}]}
                i=$((${i} + 1))
        done

        list2=(`cat ${TMPFILE}`)
        for i in "${list[@]}"; do
                echo ${i}
        done

        while read line; do
                echo ${line}
        done < ${TMPFILE}
}

init
main "$@"

◆Makefileサンプル
csrc/Makefile

CC=gcc
CFLAGS ?= -O2 -Wall
LDFLAGS ?=

OBJS=main.o
TARGET=test

.PHONY: all clean
all: $(TARGET)

$(TARGET): $(OBJS)
        $(CC) -o $@ $^ $(LDFLAGS)

debug:
        $(MAKE) -C . CFLAGS="$(CFLAGS) -DDEBUG"

.c.o:
        $(CC) -c $< $(CFLAGS)

clean:
        $(RM) $(TARGET) $(OBJS)
上記サンプル↓
$ curl -O http://sstea.blog.jp/raspi/csrc/Makefile

csrc/main.c

#include <stdio.h>

#ifdef DEBUG
#define DEBUG(...)    printf("<DEBUG> " __VA_ARGS__)
#else /* !DEBUG */
#define DEBUG(...)    do { } while (0)
#endif /* !DEBUG */

int main(int argc, char **argv)
{
    DEBUG("hello\n");
    return 0;
}

◆Linux LKM(ローダブルカーネルモジュール)サンプル
kbuild/Makefile (KDIR は場合によっては任意に変更)
obj-y := test/

KDIR ?= /lib/module/$(shell uname -r)/build
PWD := $(shell pwd)

EXTRA_CFLAGS =

modules:
    make -C $(KDIR) M=$(PWD) V=1 modules

clean:
    make -C $(KDIR) M=$(PWD) V=1 clean
上記サンプル↓
$ curl -O http://sstea.blog.jp/raspi/kbuild/Makefile

kbuild/test/Makefile
obj-m:= test.o

test-objs := test_base.o
test-objs に.oファイルを複数指定することで、複数ファイルから1つのローダブルカーネルモジュール(.koファイル)を作成可能。

kbuild/test/test_base.c
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>

static int __init test_init(void)
{
    printk("test_init\n");
    return 0;
}
module_init(test_init);

static void __exit test_exit(void)
{
    printk("test_exit\n");
}
module_exit(test_exit);

プライバシーポリシー
当サイトでは、Googleを含む第三者配信事業者や広告ネットワークが配信する広告を掲載しています。
当サイトでは、アクセス情報に基づいた適切な広告表示、及びトラフィックデータ収集のためにCookieを使用しています。
ユーザーはCookieの無効化により、これらの情報の提供を拒否する事ができます。
スポンサーリンク
記事検索
スポンサーリンク