亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? access.c

?? LINUX設備驅動2源代碼
?? C
字號:
/* * access.c -- the files with access control on open (v2.1) * */ #ifndef __KERNEL__#  define __KERNEL__#endif#ifndef MODULE#  define MODULE#endif#define __NO_VERSION__#include <linux/module.h> /* get MOD_DEC_USE_COUNT, not the version string */#include <linux/version.h> /* need it for conditionals in scull.h */#include <linux/kernel.h> /* printk() */#include <linux/malloc.h> /* kmalloc() */#include <linux/fs.h>     /* everything... */#include <linux/proc_fs.h>#include <linux/errno.h>  /* error codes */#include <linux/types.h>  /* size_t */#include <linux/fcntl.h>#include <linux/tty.h>    /* current->tty */#include "scull.h"        /* local definitions *//* * These devices fall back on the main scull operations. They only * differ in the implementation of open() and close() *//************************************************************************ * * The first device is the single-open one, *  it has an hw structure and an open count */ Scull_Dev scull_s_device; int scull_s_count = 0;int scull_s_open (struct inode *inode, struct file *filp){    Scull_Dev *dev = &scull_s_device; /* device information */    int num = NUM(inode->i_rdev);    if (num > 0) return -ENODEV; /* 1 device only */    if (scull_s_count) return -EBUSY; /* already open */    scull_s_count++;    /* then, everything else is copied from the bare scull device */    if ( (filp->f_flags & O_ACCMODE) == O_WRONLY)        scull_trim(dev);    filp->private_data = dev;    MOD_INC_USE_COUNT;    return 0;          /* success */}release_t scull_s_release (struct inode *inode, struct file *filp){    scull_s_count--; /* release the device */    MOD_DEC_USE_COUNT;    release_return(0);}/* * The other operations for the single-open device come from the bare device */struct file_operations scull_sngl_fops = {    scull_lseek,    scull_read,    scull_write,    NULL,          /* scull_readdir */    NULL,          /* scull_select */    scull_ioctl,    NULL,          /* scull_mmap */    scull_s_open,    scull_s_release,    NULL,          /* scull_fsync */    NULL,          /* scull_fasync */                   /* nothing more, fill with NULLs */};/************************************************************************ * * Next, the "uid" device. It can be opened multiple times by the * same user, but access is denied to other users if the device is open */Scull_Dev scull_u_device;int scull_u_count = 0;uid_t scull_u_owner = 0;int scull_u_open (struct inode *inode, struct file *filp){    Scull_Dev *dev = &scull_u_device; /* device information */    int num = NUM(inode->i_rdev);    if (num > 0) return -ENODEV; /* 1 device only */    if (scull_u_count &&         (scull_u_owner != current->uid) &&  /* allow user */        (scull_u_owner != current->euid) && /* allow whoever did su */        !suser()) /* still allow root */         return -EBUSY;   /* -EPERM would confuse the user */    if (scull_u_count == 0)        scull_u_owner = current->uid; /* grab it */    scull_u_count++;    /* then, everything else is copied from the bare scull device */    if ( (filp->f_flags & O_ACCMODE) == O_WRONLY)        scull_trim(dev);    filp->private_data = dev;    MOD_INC_USE_COUNT;    return 0;          /* success */}release_t scull_u_release (struct inode *inode, struct file *filp){    scull_u_count--; /* nothing else */    MOD_DEC_USE_COUNT;    release_return(0);}/* * The other operations for the device come from the bare device */struct file_operations scull_user_fops = {    scull_lseek,    scull_read,    scull_write,    NULL,          /* scull_readdir */    NULL,          /* scull_select */    scull_ioctl,    NULL,          /* scull_mmap */    scull_u_open,    scull_u_release,    NULL,          /* scull_fsync */    NULL,          /* scull_fasync */                   /* nothing more, fill with NULLs */};/************************************************************************ * * Next, the device with blocking-open based on uid */Scull_Dev scull_w_device;int scull_w_count = 0;uid_t scull_w_owner = 0;struct wait_queue *scull_w_wait;int scull_w_open (struct inode *inode, struct file *filp){    Scull_Dev *dev = &scull_w_device; /* device information */    int num = NUM(inode->i_rdev);    if (num > 0) return -ENODEV; /* 1 device only */    while (scull_w_count &&       (scull_w_owner != current->uid) &&  /* allow user */      (scull_w_owner != current->euid) && /* allow whoever did su */      !suser()) {        if (filp->f_flags & O_NONBLOCK) return -EAGAIN;         interruptible_sleep_on(&scull_w_wait);        if (current->signal & ~current->blocked) /* a signal arrived */          return -ERESTARTSYS; /* tell the fs layer to handle it */        /* else, loop */    }    if (scull_w_count == 0)        scull_w_owner = current->uid; /* grab it */    scull_w_count++;    /* then, everything else is copied from the bare scull device */    if ( (filp->f_flags & O_ACCMODE) == O_WRONLY)        scull_trim(dev);    filp->private_data = dev;    MOD_INC_USE_COUNT;    return 0;          /* success */}release_t scull_w_release (struct inode *inode, struct file *filp){    scull_w_count--;    if (scull_w_count == 0)        wake_up_interruptible(&scull_w_wait); /* awake other uid's */    MOD_DEC_USE_COUNT;    release_return(0);}/* * The other operations for the device come from the bare device */struct file_operations scull_wusr_fops = {    scull_lseek,    scull_read,    scull_write,    NULL,          /* scull_readdir */    NULL,          /* scull_select */    scull_ioctl,    NULL,          /* scull_mmap */    scull_w_open,    scull_w_release,    NULL,          /* scull_fsync */    NULL,          /* scull_fasync */                   /* nothing more, fill with NULLs */};/************************************************************************ * * Finally the `cloned' private device. This is trickier because it * involves list management, and dynamic allocation. */struct scull_listitem {    Scull_Dev device;    int key;    struct scull_listitem *next;};struct scull_listitem *scull_c_head;int scull_c_open (struct inode *inode, struct file *filp){    int key;    int num = NUM(inode->i_rdev);    struct scull_listitem *lptr, *prev;    if (num > 0) return -ENODEV; /* 1 device only */    if (!current->tty) {        PDEBUG("Process \"%s\" has no ctl tty\n",current->comm);        return -EINVAL;    }    key = MINOR(current->tty->device);    /* look for a device in the linked list; if missing create it */    prev = NULL;    for (lptr = scull_c_head; lptr && (lptr->key != key); lptr = lptr->next)        prev=lptr;    if (!lptr) { /* not found */        lptr = kmalloc(sizeof(struct scull_listitem), GFP_KERNEL);        if (!lptr)            return -ENOMEM;        memset(lptr, 0, sizeof(struct scull_listitem));        lptr->key = key;        scull_trim(&(lptr->device)); /* initialize it */        if (prev)            prev->next = lptr;        else            scull_c_head = lptr; /* the first one */    }    /* then, everything else is copied from the bare scull device */    if ( (filp->f_flags & O_ACCMODE) == O_WRONLY)        scull_trim(&(lptr->device));    filp->private_data = &(lptr->device);    MOD_INC_USE_COUNT;    return 0;          /* success */}release_t scull_c_release (struct inode *inode, struct file *filp){    /*     * Nothing to do, because the device is persistent.     * A `real' cloned device should be freed on last close     */    MOD_DEC_USE_COUNT;    release_return(0);}/* * The other operations for the device come from the bare device */struct file_operations scull_priv_fops = {    scull_lseek,    scull_read,    scull_write,    NULL,          /* scull_readdir */    NULL,          /* scull_select */    scull_ioctl,    NULL,          /* scull_mmap */    scull_c_open,    scull_c_release,    NULL,          /* scull_fsync */    NULL,          /* scull_fasync */                   /* nothing more, fill with NULLs */};/************************************************************************ * * And the init and cleanup functions come last */int scull_access_init(void){    /* assign quantum and quantumset */    scull_s_device.quantum = scull_quantum;    scull_s_device.qset    = scull_qset;    scull_u_device.quantum = scull_quantum;    scull_u_device.qset    = scull_qset;    scull_w_device.quantum = scull_quantum;    scull_w_device.qset    = scull_qset;    return 0;}void scull_access_cleanup(void) /* called by cleanup_module */{    struct scull_listitem *lptr, *prev;    scull_trim(&scull_s_device); /* disallocate it */    scull_trim(&scull_u_device); /* disallocate it */    scull_trim(&scull_w_device); /* disallocate it */    /* all the cloned devices */    prev=NULL;    for (lptr = scull_c_head; lptr; lptr = lptr->next) {        scull_trim(&(lptr->device));        if (prev) kfree(prev);        prev=lptr;    }    if (prev) kfree(prev);    scull_c_head = NULL; /* overkill: we're unloading anyways */    return;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91精品在线观看| 精品人伦一区二区色婷婷| 日韩一区二区三区视频在线观看| 久久精品日产第一区二区三区高清版 | av一二三不卡影片| 欧美肥大bbwbbw高潮| 综合久久久久久久| 国产成人精品网址| 久久综合狠狠综合久久综合88 | 99这里只有精品| 精品播放一区二区| 午夜精品福利久久久| 色综合久久中文综合久久牛| 337p日本欧洲亚洲大胆色噜噜| 午夜精品一区二区三区电影天堂| 91美女视频网站| 亚洲欧美怡红院| 懂色av一区二区夜夜嗨| 久久久久久麻豆| 免费看日韩a级影片| 欧美精选在线播放| 亚洲一区二区视频| 色综合久久综合网97色综合 | 夜夜嗨av一区二区三区| 91麻豆免费在线观看| 国产精品不卡在线观看| 99精品视频在线观看免费| 亚洲国产精品成人综合| 成人精品国产免费网站| 中文字幕二三区不卡| 波多野结衣中文字幕一区二区三区| 久久综合狠狠综合久久激情| 精品一区二区三区在线视频| 精品久久久久99| 久久99精品国产麻豆婷婷| 精品日韩99亚洲| 国产乱理伦片在线观看夜一区| 亚洲精品一区二区三区影院| 国模娜娜一区二区三区| 国产亚洲综合av| 成人av先锋影音| 亚洲人一二三区| 欧美日韩一区久久| 午夜不卡av在线| 日韩情涩欧美日韩视频| 国产乱国产乱300精品| 国产精品三级av在线播放| 成人av免费在线播放| 有坂深雪av一区二区精品| 欧美日韩日日骚| 精品伊人久久久久7777人| 日本一区二区三区dvd视频在线| 成人性生交大片免费| 亚洲精选免费视频| 7777精品伊人久久久大香线蕉超级流畅| 视频一区二区三区中文字幕| 精品免费一区二区三区| 国产成人精品影视| 一区二区三区在线观看视频| 欧美一级夜夜爽| 国产精品亚洲成人| 一区二区三区在线看| 精品国产乱码久久久久久久久| 成人亚洲一区二区一| 亚洲国产成人91porn| 国产亚洲婷婷免费| 欧美在线观看一区| 国产在线乱码一区二区三区| 亚洲卡通欧美制服中文| 精品处破学生在线二十三| 91香蕉视频mp4| 激情欧美一区二区三区在线观看| 最近中文字幕一区二区三区| 欧美va亚洲va| 欧美日韩一级二级三级| 成人做爰69片免费看网站| 亚洲成人手机在线| 国产精品欧美极品| 精品免费99久久| 欧美伊人久久大香线蕉综合69| 久久69国产一区二区蜜臀| 一区二区三区四区乱视频| wwww国产精品欧美| 欧美一卡二卡三卡四卡| 在线免费一区三区| 成人高清在线视频| 精品综合久久久久久8888| 午夜影院在线观看欧美| 亚洲色图20p| 国产精品素人一区二区| 日韩免费视频线观看| 欧美美女一区二区三区| 92国产精品观看| 成人免费毛片app| 精品在线免费视频| 蜜桃av一区二区在线观看| 亚洲一级二级在线| 亚洲免费看黄网站| 国产精品白丝在线| 国产精品无圣光一区二区| 国产偷国产偷精品高清尤物| 欧美大片在线观看一区| 3atv一区二区三区| 欧美精品久久久久久久久老牛影院 | 激情综合色播激情啊| 免费观看在线综合| 麻豆中文一区二区| 日韩黄色片在线观看| 日本怡春院一区二区| 日韩av一区二区三区四区| 亚洲h在线观看| 亚洲成a人片在线不卡一二三区| 亚洲精品视频在线观看免费| 亚洲免费大片在线观看| 一区二区免费看| 一区二区三区.www| 午夜精品久久久久影视| 亚洲观看高清完整版在线观看| 亚洲成a人在线观看| 日韩高清欧美激情| 美国三级日本三级久久99| 免费在线观看视频一区| 狠狠狠色丁香婷婷综合激情| 国产成人在线网站| 成人国产视频在线观看| 色婷婷久久一区二区三区麻豆| 欧美又粗又大又爽| 欧美日韩国产在线观看| 在线不卡中文字幕| 精品日韩成人av| 亚洲国产精品激情在线观看| 最近日韩中文字幕| 三级精品在线观看| 国产主播一区二区三区| www.综合网.com| 欧美日韩一区久久| 亚洲精品一区二区三区99| 日本一区二区三区国色天香| 亚洲专区一二三| 精品午夜一区二区三区在线观看| 国产不卡高清在线观看视频| 色香蕉久久蜜桃| 欧美大度的电影原声| 国产精品视频麻豆| 亚洲bt欧美bt精品| 国产不卡视频在线播放| 欧美在线免费观看视频| 精品国产乱码久久久久久1区2区 | av成人免费在线观看| 欧美色手机在线观看| 欧美精品一区二区三区四区| √…a在线天堂一区| 日韩二区在线观看| 成人黄色大片在线观看| 91超碰这里只有精品国产| 亚洲国产精华液网站w| 三级在线观看一区二区| 成人美女视频在线观看| 69精品人人人人| 亚洲欧美日韩久久精品| 激情都市一区二区| 欧美午夜精品免费| 国产欧美在线观看一区| 天天爽夜夜爽夜夜爽精品视频| 成人国产免费视频| 日韩欧美不卡一区| 亚洲综合激情小说| 成人免费三级在线| 2022国产精品视频| 日韩国产欧美三级| 色婷婷国产精品综合在线观看| 欧美成人精品高清在线播放| 亚洲国产人成综合网站| 99久久伊人精品| 久久九九影视网| 另类的小说在线视频另类成人小视频在线 | 久久尤物电影视频在线观看| 天堂精品中文字幕在线| 91在线观看污| 国产精品美女久久久久久久久久久 | 国产亚洲成年网址在线观看| 五月天一区二区三区| 一本一道波多野结衣一区二区| 欧美经典三级视频一区二区三区| 日韩av午夜在线观看| 欧美日韩国产三级| 亚洲成国产人片在线观看| 色综合色综合色综合色综合色综合 | 国产精品视频一二三| 久久福利资源站| 欧美一卡二卡三卡四卡| 天堂一区二区在线免费观看| 欧美综合一区二区三区| 亚洲人成7777| 93久久精品日日躁夜夜躁欧美| 国产精品区一区二区三区| 国产福利精品一区| 久久久久国产精品麻豆| 国产风韵犹存在线视精品| 久久久久久久久99精品|