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

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

?? access.c

?? LINUX設備驅動2源代碼
?? C
字號:
/* * access.c -- the files with access control on open * * Tested with 1.2 on the x86 * Tested with 2.0 on the x86, Sparc */ #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 */}void scull_s_release (struct inode *inode, struct file *filp){    scull_s_count--; /* release the device */    MOD_DEC_USE_COUNT;    return;}/* * 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 */}void scull_u_release (struct inode *inode, struct file *filp){    scull_u_count--; /* nothing else */    MOD_DEC_USE_COUNT;    return;}/* * 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 */}void 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;    return;}/* * 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 */}void 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;    return;}/* * 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一区二区三区免费野_久草精品视频
欧美午夜在线观看| 国产精品天天看| 日本一区二区电影| 舔着乳尖日韩一区| 99久久免费视频.com| 精品久久人人做人人爰| 亚洲欧美日韩国产成人精品影院 | 美美哒免费高清在线观看视频一区二区| 精品午夜一区二区三区在线观看 | 国产成人日日夜夜| 制服丝袜激情欧洲亚洲| 亚洲欧美一区二区三区极速播放| 久久精品免费看| 欧美写真视频网站| 亚洲天堂成人在线观看| 国产成人精品aa毛片| 日韩欧美一级特黄在线播放| 亚洲国产精品欧美一二99| 色噜噜久久综合| 国产精品久久国产精麻豆99网站| 国产一区亚洲一区| 日韩亚洲欧美中文三级| 亚洲国产一区二区视频| 欧美在线视频不卡| 亚洲日本成人在线观看| 成人91在线观看| 国产精品久久久久7777按摩| 暴力调教一区二区三区| 亚洲国产成人私人影院tom| 国产成人三级在线观看| 国产女人18水真多18精品一级做| 激情欧美一区二区三区在线观看| 日韩欧美久久久| 久久99精品网久久| 久久久久久久久久久久电影| 国产乱色国产精品免费视频| 久久美女艺术照精彩视频福利播放| 久久狠狠亚洲综合| 精品剧情在线观看| 国产精品自拍网站| 国产精品区一区二区三区| 成人ar影院免费观看视频| 亚洲狼人国产精品| 欧美日韩一级片在线观看| 午夜视频在线观看一区二区| 欧美丰满嫩嫩电影| 国精产品一区一区三区mba桃花| 26uuu色噜噜精品一区| 成人激情综合网站| 亚洲综合久久av| 日韩精品在线看片z| 国产乱子轮精品视频| 成人欧美一区二区三区黑人麻豆| 日本韩国欧美一区| 视频一区二区三区中文字幕| 欧美成人猛片aaaaaaa| 高清免费成人av| 亚洲激情成人在线| 欧美xxxxx裸体时装秀| 成人国产精品视频| 五月婷婷另类国产| 国产日韩欧美不卡在线| 在线亚洲人成电影网站色www| 天天综合网 天天综合色| 久久久亚洲精华液精华液精华液| 波多野结衣亚洲| 石原莉奈在线亚洲二区| 国产精品色哟哟网站| 制服丝袜亚洲色图| 成人av电影观看| 麻豆精品久久精品色综合| 中文字幕在线播放不卡一区| 在线电影院国产精品| 成人三级伦理片| 蜜乳av一区二区| 中文字幕综合网| 欧美精品一区二区久久婷婷| 91久久国产最好的精华液| 韩国v欧美v亚洲v日本v| 亚洲香肠在线观看| 欧美激情一区二区在线| 欧美一区二区三区四区在线观看| 成人av影视在线观看| 青娱乐精品视频在线| 亚洲精品欧美激情| 久久久午夜电影| 777奇米四色成人影色区| aaa亚洲精品一二三区| 韩国欧美国产1区| 美女视频一区二区| 亚洲自拍都市欧美小说| 亚洲区小说区图片区qvod| 久久久久久久国产精品影院| 欧美日韩国产精品自在自线| 欧美性生交片4| 不卡在线视频中文字幕| 国产91综合一区在线观看| 日本视频一区二区| 亚洲成a天堂v人片| 夜夜爽夜夜爽精品视频| 国产精品成人一区二区三区夜夜夜| 精品国产一区二区三区av性色| 欧美性做爰猛烈叫床潮| 色婷婷精品大视频在线蜜桃视频| 国产成人精品一区二| 国产一区在线精品| 久久精品国产**网站演员| 免费的国产精品| 日韩精品色哟哟| 图片区小说区区亚洲影院| 午夜精品久久久久久不卡8050| 亚洲乱码国产乱码精品精可以看| 国产精品福利av | 欧美精品亚洲二区| 欧美日韩精品系列| 欧美日韩国产高清一区二区| 欧美日韩高清不卡| 7777精品伊人久久久大香线蕉完整版| 欧美性一二三区| 欧美性欧美巨大黑白大战| 91麻豆成人久久精品二区三区| 99久久伊人精品| 在线亚洲一区观看| 91麻豆精品国产自产在线观看一区| 欧美日韩一区小说| 日韩一区二区三区高清免费看看 | 蜜桃精品在线观看| 精品制服美女丁香| 懂色av中文字幕一区二区三区| 成人午夜激情影院| 在线看国产日韩| 欧美日韩亚洲不卡| 日韩区在线观看| 欧美激情综合五月色丁香小说| 亚洲人成在线播放网站岛国| 夜夜嗨av一区二区三区中文字幕 | 丁香一区二区三区| 粉嫩13p一区二区三区| 一本色道久久综合精品竹菊| 欧美情侣在线播放| 欧美成人伊人久久综合网| 国产精品久久久久天堂| 亚洲图片一区二区| 国产一区视频导航| 91蜜桃免费观看视频| 91精品国产91综合久久蜜臀| 久久精品人人做人人综合| 亚洲乱码国产乱码精品精小说| 日产精品久久久久久久性色| 国产成人在线视频播放| 欧美色爱综合网| 亚洲午夜日本在线观看| 久久激情综合网| 色婷婷综合激情| 久久影视一区二区| 亚洲在线视频网站| 国产老肥熟一区二区三区| 在线观看欧美日本| 久久久久国产成人精品亚洲午夜| 亚洲三级久久久| 国内精品国产成人| 精品视频一区二区不卡| 国产无遮挡一区二区三区毛片日本| 亚洲美女免费在线| 国产精品亚洲一区二区三区妖精| 欧洲亚洲国产日韩| 中文字幕一区二区三区av| 精品一区二区免费视频| 欧美日韩你懂得| 一区在线观看免费| 国内精品久久久久影院色| 欧美二区在线观看| 亚洲精品欧美激情| 99精品视频在线观看免费| 久久你懂得1024| 免费在线观看不卡| 欧美性色黄大片手机版| 亚洲激情网站免费观看| 成人精品一区二区三区中文字幕| 欧美一区二区三区免费视频| 亚洲黄色免费网站| 99久久精品免费看| 国产精品麻豆视频| 国产成人99久久亚洲综合精品| 亚洲精品免费在线| 成人黄色软件下载| 国产精品久久久久精k8| 国产99久久久国产精品潘金网站| 日韩美一区二区三区| 免费在线看成人av| 日韩三级视频在线观看| 日韩精品1区2区3区| 欧美日韩电影在线| 丝袜亚洲另类丝袜在线| 欧美绝品在线观看成人午夜影视| 亚洲午夜久久久久久久久电影网| 日本高清成人免费播放| 夜夜精品视频一区二区| 欧美日韩和欧美的一区二区| 亚洲成人一区二区|