Igor Sysoev | 9cf7830 | 2003-06-04 17:28:33 +0000 | [diff] [blame] | 1 | |
| 2 | #include <ngx_config.h> |
| 3 | #include <ngx_core.h> |
| 4 | |
| 5 | |
| 6 | /* STUB */ |
| 7 | ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size); |
| 8 | ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in); |
| 9 | int ngx_posix_init(ngx_log_t *log); |
| 10 | |
| 11 | |
| 12 | char ngx_linux_kern_ostype[50]; |
| 13 | char ngx_linux_kern_osrelease[20]; |
| 14 | |
| 15 | |
| 16 | ngx_os_io_t ngx_os_io = { |
| 17 | ngx_unix_recv, |
| 18 | NULL, |
| 19 | NULL, |
| 20 | ngx_writev_chain, |
| 21 | NGX_HAVE_ZEROCOPY |
| 22 | }; |
| 23 | |
| 24 | |
| 25 | int ngx_os_init(ngx_log_t *log) |
| 26 | { |
| 27 | int name[2], len; |
| 28 | |
| 29 | name[0] = CTL_KERN; |
| 30 | name[1] = KERN_OSTYPE; |
| 31 | len = sizeof(ngx_linux_kern_ostype); |
| 32 | if (sysctl(name, sizeof(name), ngx_linux_kern_ostype, &len, NULL, 0) |
| 33 | == -1) { |
| 34 | ngx_log_error(NGX_LOG_ALERT, log, errno, "sysctl(KERN_OSTYPE) failed"); |
| 35 | return NGX_ERROR; |
| 36 | } |
| 37 | |
| 38 | name[0] = CTL_KERN; |
| 39 | name[1] = KERN_OSRELEASE; |
| 40 | len = sizeof(ngx_linux_kern_osrelease); |
| 41 | if (sysctl(name, sizeof(name), ngx_linux_kern_osrelease, &len, NULL, 0) |
| 42 | == -1) { |
| 43 | ngx_log_error(NGX_LOG_ALERT, log, errno, |
| 44 | "sysctl(KERN_OSRELEASE) failed"); |
| 45 | return NGX_ERROR; |
| 46 | } |
| 47 | |
| 48 | ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %s %s", |
| 49 | ngx_linux_kern_ostype, ngx_linux_kern_osrelease); |
| 50 | |
| 51 | |
| 52 | return ngx_posix_init(log); |
| 53 | } |