linux-old/kernel/info.c
<<
>>
Prefs
   1/*
   2 * linux/kernel/info.c
   3 *
   4 * Copyright (C) 1992 Darren Senn
   5 */
   6
   7/* This implements the sysinfo() system call */
   8
   9#include <linux/sched.h>
  10#include <linux/string.h>
  11#include <linux/unistd.h>
  12#include <linux/types.h>
  13#include <linux/mm.h>
  14#include <linux/swap.h>
  15#include <linux/smp.h>
  16#include <linux/smp_lock.h>
  17
  18#include <asm/uaccess.h>
  19
  20asmlinkage int sys_sysinfo(struct sysinfo *info)
  21{
  22        struct sysinfo val;
  23
  24        memset((char *)&val, 0, sizeof(struct sysinfo));
  25
  26        cli();
  27        val.uptime = jiffies / HZ;
  28
  29        val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
  30        val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
  31        val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT);
  32
  33        val.procs = nr_tasks-1;
  34        sti();
  35
  36        si_meminfo(&val);
  37        si_swapinfo(&val);
  38
  39        if (copy_to_user(info, &val, sizeof(struct sysinfo)))
  40                return -EFAULT;
  41        return 0;
  42}
  43
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.