src/os/unix/ngx_linux_init.c - nginx source code

Global variables defined

Functions defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #include <ngx_config.h>
  6. #include <ngx_core.h>


  7. u_char  ngx_linux_kern_ostype[50];
  8. u_char  ngx_linux_kern_osrelease[50];


  9. static ngx_os_io_t ngx_linux_io = {
  10.     ngx_unix_recv,
  11.     ngx_readv_chain,
  12.     ngx_udp_unix_recv,
  13.     ngx_unix_send,
  14.     ngx_udp_unix_send,
  15.     ngx_udp_unix_sendmsg_chain,
  16. #if (NGX_HAVE_SENDFILE)
  17.     ngx_linux_sendfile_chain,
  18.     NGX_IO_SENDFILE
  19. #else
  20.     ngx_writev_chain,
  21.     0
  22. #endif
  23. };


  24. ngx_int_t
  25. ngx_os_specific_init(ngx_log_t *log)
  26. {
  27.     struct utsname  u;

  28.     if (uname(&u) == -1) {
  29.         ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "uname() failed");
  30.         return NGX_ERROR;
  31.     }

  32.     (void) ngx_cpystrn(ngx_linux_kern_ostype, (u_char *) u.sysname,
  33.                        sizeof(ngx_linux_kern_ostype));

  34.     (void) ngx_cpystrn(ngx_linux_kern_osrelease, (u_char *) u.release,
  35.                        sizeof(ngx_linux_kern_osrelease));

  36.     ngx_os_io = ngx_linux_io;

  37.     return NGX_OK;
  38. }


  39. void
  40. ngx_os_specific_status(ngx_log_t *log)
  41. {
  42.     ngx_log_error(NGX_LOG_NOTICE, log, 0, "OS: %s %s",
  43.                   ngx_linux_kern_ostype, ngx_linux_kern_osrelease);
  44. }