📄 tid_proc.c
字号:
/*********************************************************************** * * (C) Copyright 2000 * Jean-Jacques Germond, Fr閐閞ic Soulier, Christian Batt; Alcatel * C/O jjg@sxb.bsf.alcatel.fr * * All rights reserved. * * This code is free software; you can redistribute it and/or * modify it under the terms of the GNU *Library* General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This code is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * *Library* General Public License for more details. * * You should have received a copy of the GNU *Library* General Public * License along with this program (see file COPYING.LIB); if not, * write to the Free Software Foundation, Inc., 675 Mass Ave, * Cambridge, MA 02139, USA. * ***********************************************************************//* The "trivial module" /proc routines (see AR pg: 74) *//* This should be a module of its own */#define __NO_VERSION__#include "tid_def.h"#ifndef CONFIG_PROC_FS# define CONFIG_PROC_FS /* This is for proc_fs.h */#endif#include "linux/proc_fs.h" inttid_edit_mem(char* b, char **start, off_t offset, int len, int unused) /* Edit the Trivial device info */{ Tid_Dev *dev = &tid_dev_struct; /* The device descriptor */ int x; /* The store index in the output page */ x = sprintf(b, "***tid0:\n"); /* This code does not check for output buffer overflow. * We must do such checks if our output tends to become more voluminous. */ x += sprintf (b+x, " %s= %8lx\n", "# of chars in the device ", (long)dev->nbChars); x += sprintf (b+x, " %s= %8lx\n", "# of resets ", dev->uniqueId); x += sprintf (b+x, " %s= %8lx\n", "Max # of chars ", (long)dev->maxChars); x += sprintf (b+x, " %s= %8lx\n", "# of bh activations ", dev->nbBhActiv); x += sprintf (b+x, " %s= %8lx\n", "# of interrutps since init ", dev->nbIntrEver); x += sprintf (b+x, " %s= %8lx\n", "# of wakeups since init ", dev->nbWakeUp); x += sprintf (b+x, " %s= %8lx\n", "last wakeup code ", dev->lastWakeup); return x; /* Do not count the trailing zero */}static struct proc_dir_entry tid_proc_entry = { 0, /* low_ino: the inode -- dynamic */ 6, "tidmem", /* len of name and name */ S_IFREG | S_IRUGO, /* mode */ 1, 0, 0, /* nlinks, owner, group */ 0, NULL, /* size - unused; operations -- use default */ &tid_edit_mem, /* function used to read data */ /* nothing more */}; inttid_proc_register(void) /* Register the trivial device in /proc */{ return proc_register(&proc_root, &tid_proc_entry);} voidtid_proc_unregister(void){ proc_unregister(&proc_root, tid_proc_entry.low_ino);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -