Mercurial > hg > nginx
annotate src/os/unix/ngx_linux_init.c @ 750:e3df50b4a4fd
fix hash building on unknown 64-bit platform
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 06 Oct 2006 15:06:02 +0000 |
parents | b80f94fa2197 |
children | 82528072f415 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
5 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
673 | 11 static ngx_int_t ngx_linux_procfs(char *name, char *buf, size_t len, |
12 ngx_log_t *log); | |
13 | |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 |
673 | 15 char ngx_linux_kern_ostype[50]; |
16 char ngx_linux_kern_osrelease[20]; | |
17 | |
18 int ngx_linux_rtsig_max; | |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
312
diff
changeset
|
19 |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 |
539 | 21 static ngx_os_io_t ngx_linux_io = { |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 ngx_unix_recv, |
312
f5431a4bbc7d
nginx-0.0.3-2004-04-13-09:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
23 ngx_readv_chain, |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
24 ngx_unix_send, |
469 | 25 #if (NGX_HAVE_SENDFILE) |
196
11fbd0fc041d
nginx-0.0.1-2003-11-26-18:42:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
183
diff
changeset
|
26 ngx_linux_sendfile_chain, |
11fbd0fc041d
nginx-0.0.1-2003-11-26-18:42:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
183
diff
changeset
|
27 NGX_IO_SENDFILE |
312
f5431a4bbc7d
nginx-0.0.3-2004-04-13-09:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
28 #else |
f5431a4bbc7d
nginx-0.0.3-2004-04-13-09:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
29 ngx_writev_chain, |
f5431a4bbc7d
nginx-0.0.3-2004-04-13-09:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
30 0 |
f5431a4bbc7d
nginx-0.0.3-2004-04-13-09:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
31 #endif |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 }; |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 |
493 | 35 ngx_int_t |
539 | 36 ngx_os_specific_init(ngx_log_t *log) |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 { |
467 | 38 int name[2]; |
39 size_t len; | |
40 ngx_err_t err; | |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 |
673 | 42 if (ngx_linux_procfs("/proc/sys/kernel/ostype", |
43 ngx_linux_kern_ostype, | |
44 sizeof(ngx_linux_kern_ostype), log) | |
45 == -1) | |
46 { | |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 return NGX_ERROR; |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
48 } |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 |
673 | 50 if (ngx_linux_procfs("/proc/sys/kernel/osrelease", |
51 ngx_linux_kern_osrelease, | |
52 sizeof(ngx_linux_kern_osrelease), log) | |
53 == -1) | |
54 { | |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
55 return NGX_ERROR; |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 } |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
57 |
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 |
673 | 59 name[0] = CTL_KERN; |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
312
diff
changeset
|
60 name[1] = KERN_RTSIGMAX; |
450 | 61 len = sizeof(ngx_linux_rtsig_max); |
493 | 62 |
63 if (sysctl(name, 2, &ngx_linux_rtsig_max, &len, NULL, 0) == -1) { | |
467 | 64 err = ngx_errno; |
65 | |
673 | 66 if (err != NGX_ENOTDIR && err != NGX_ENOSYS) { |
467 | 67 ngx_log_error(NGX_LOG_ALERT, log, err, |
68 "sysctl(KERN_RTSIGMAX) failed"); | |
69 | |
70 return NGX_ERROR; | |
71 } | |
72 | |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
73 ngx_linux_rtsig_max = 0; |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
312
diff
changeset
|
74 } |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
312
diff
changeset
|
75 |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
312
diff
changeset
|
76 |
539 | 77 ngx_os_io = ngx_linux_io; |
78 | |
79 return NGX_OK; | |
101
2e069b6e6920
nginx-0.0.1-2003-06-04-21:28:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
80 } |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
81 |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
82 |
493 | 83 void |
539 | 84 ngx_os_specific_status(ngx_log_t *log) |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
85 { |
531 | 86 ngx_log_error(NGX_LOG_NOTICE, log, 0, "OS: %s %s", |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
87 ngx_linux_kern_ostype, ngx_linux_kern_osrelease); |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
88 |
531 | 89 ngx_log_error(NGX_LOG_NOTICE, log, 0, "sysctl(KERN_RTSIGMAX): %d", |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
90 ngx_linux_rtsig_max); |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
91 } |
673 | 92 |
93 | |
94 static ngx_int_t | |
95 ngx_linux_procfs(char *name, char *buf, size_t len, ngx_log_t *log) | |
96 { | |
97 int n; | |
98 ngx_fd_t fd; | |
99 | |
100 fd = open(name, O_RDONLY); | |
101 | |
102 if (fd == NGX_INVALID_FILE) { | |
103 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
104 "open(\"%s\") failed", name); | |
105 | |
106 return NGX_ERROR; | |
107 } | |
108 | |
109 n = read(fd, buf, len); | |
110 | |
111 if (n == -1) { | |
112 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
113 "read(\"%s\") failed", name); | |
114 | |
115 } else { | |
116 if (buf[n - 1] == '\n') { | |
117 buf[--n] = '\0'; | |
118 } | |
119 } | |
120 | |
121 ngx_close_file(fd); | |
122 | |
123 return n; | |
124 } |