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

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

?? access.c

?? Linux設備驅動程序第二版
?? C
字號:
/* * access.c -- the files with access control on open * * $Id: access.c,v 1.19 2001/03/16 21:04:49 rubini Exp $ */ #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/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 following deals with some of the 2.2 API changes. */#ifdef LINUX_20extern int scull_lseek_20(struct inode *ino, struct file *f, off_t offset,                int whence);extern int scull_read_20(struct inode *ino, struct file *f, char *buf,                int count);extern int scull_write_20(struct inode *ino, struct file *f, const char *buf,                int count);#define scull_llseek scull_lseek_20#define scull_read   scull_read_20#define scull_write  scull_write_20#endif/************************************************************************ * * 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;spinlock_t scull_s_lock;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 (!filp->private_data && num > 0)        return -ENODEV; /* not devfs: allow 1 device only */    spin_lock(&scull_s_lock);    if (scull_s_count) {        spin_unlock(&scull_s_lock);        return -EBUSY; /* already open */    }    scull_s_count++;    spin_unlock(&scull_s_lock);    /* then, everything else is copied from the bare scull device */    if ( (filp->f_flags & O_ACCMODE) == O_WRONLY)        scull_trim(dev);    if (!filp->private_data)        filp->private_data = dev;    MOD_INC_USE_COUNT;    return 0;          /* success */}int scull_s_release(struct inode *inode, struct file *filp){    scull_s_count--; /* release the device */    MOD_DEC_USE_COUNT;    return 0;}#ifdef LINUX_20void scull_s_release_20(struct inode *ino, struct file *f){    scull_s_release(ino, f);}#define scull_s_release scull_s_release_20#define llseek lseek#endif/* * The other operations for the single-open device come from the bare device */struct file_operations scull_sngl_fops = {    llseek:     scull_llseek,    read:       scull_read,    write:      scull_write,    ioctl:      scull_ioctl,    open:       scull_s_open,    release:    scull_s_release,};/************************************************************************ * * 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;spinlock_t scull_u_lock;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 (!filp->private_data && num > 0)        return -ENODEV; /* not devfs: allow 1 device only */    spin_lock(&scull_u_lock);    if (scull_u_count &&         (scull_u_owner != current->uid) &&  /* allow user */        (scull_u_owner != current->euid) && /* allow whoever did su */                    !capable(CAP_DAC_OVERRIDE)) { /* still allow root */            spin_unlock(&scull_u_lock);            return -EBUSY;   /* -EPERM would confuse the user */    }    if (scull_u_count == 0)        scull_u_owner = current->uid; /* grab it */    scull_u_count++;    spin_unlock(&scull_u_lock);    /* then, everything else is copied from the bare scull device */    if ( (filp->f_flags & O_ACCMODE) == O_WRONLY)        scull_trim(dev);    if (!filp->private_data)        filp->private_data = dev;    MOD_INC_USE_COUNT;    return 0;          /* success */}int scull_u_release(struct inode *inode, struct file *filp){    scull_u_count--; /* nothing else */    MOD_DEC_USE_COUNT;    return 0;}#ifdef LINUX_20void scull_u_release_20(struct inode *ino, struct file *f){    scull_u_release(ino, f);}#define scull_u_release scull_u_release_20#endif/* * The other operations for the device come from the bare device */struct file_operations scull_user_fops = {    llseek:     scull_llseek,    read:       scull_read,    write:      scull_write,    ioctl:      scull_ioctl,    open:       scull_u_open,    release:    scull_u_release,};/************************************************************************ * * 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;static DECLARE_WAIT_QUEUE_HEAD(scull_w_wait);spinlock_t scull_w_lock;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 (!filp->private_data && num > 0)        return -ENODEV; /* not devfs: allow 1 device only */    spin_lock(&scull_w_lock);    while (scull_w_count &&       (scull_w_owner != current->uid) &&  /* allow user */      (scull_w_owner != current->euid) && /* allow whoever did su */      !capable(CAP_DAC_OVERRIDE)) {        spin_unlock(&scull_w_lock);        if (filp->f_flags & O_NONBLOCK) return -EAGAIN;         interruptible_sleep_on(&scull_w_wait);        if (signal_pending(current)) /* a signal arrived */          return -ERESTARTSYS; /* tell the fs layer to handle it */        /* else, loop */        spin_lock(&scull_w_lock);    }    if (scull_w_count == 0)        scull_w_owner = current->uid; /* grab it */    scull_w_count++;    spin_unlock(&scull_w_lock);    /* then, everything else is copied from the bare scull device */    if ( (filp->f_flags & O_ACCMODE) == O_WRONLY)        scull_trim(dev);    if (!filp->private_data)        filp->private_data = dev;    MOD_INC_USE_COUNT;    return 0;          /* success */}int 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 0;}#ifdef LINUX_20void scull_w_release_20(struct inode *ino, struct file *f){    scull_w_release(ino, f);}#define scull_w_release scull_w_release_20#endif/* * The other operations for the device come from the bare device */struct file_operations scull_wusr_fops = {    llseek:     scull_llseek,    read:       scull_read,    write:      scull_write,    ioctl:      scull_ioctl,    open:       scull_w_open,    release:    scull_w_release,};/************************************************************************ * * Finally the `cloned' private device. This is trickier because it * involves list management, and dynamic allocation. */devfs_handle_t scull_priv_handle;    /* only used if devfs is there *//* The clone-specific data structure includes a key field */struct scull_listitem {    Scull_Dev device;    int key;    struct scull_listitem *next;    };/* The list of devices, and a lock to protect it */struct scull_listitem *scull_c_head;spinlock_t scull_c_lock;/* Look for a device or create one if missing */static Scull_Dev *scull_c_lookfor_device(int key){    struct scull_listitem *lptr, *prev = NULL;    for (lptr = scull_c_head; lptr && (lptr->key != key); lptr = lptr->next)        prev=lptr;    if (lptr) return &(lptr->device);    /* not found */    lptr = kmalloc(sizeof(struct scull_listitem), GFP_ATOMIC);    if (!lptr) return NULL;    /* initialize the device */    memset(lptr, 0, sizeof(struct scull_listitem));    lptr->key = key;    scull_trim(&(lptr->device)); /* initialize it */    sema_init(&(lptr->device.sem), 1);    /* place it in the list */    if (prev)  prev->next = lptr;    else       scull_c_head = lptr;    return &(lptr->device);}int scull_c_open(struct inode *inode, struct file *filp){    Scull_Dev *dev;    int key, num = NUM(inode->i_rdev);     if (!filp->private_data && num > 0)        return -ENODEV; /* not devfs: allow 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 scullc device in the list */    spin_lock(&scull_c_lock);    dev = scull_c_lookfor_device(key);    spin_unlock(&scull_c_lock);    if (!dev) return -ENOMEM;    /* 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 */}int 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 0;}#ifdef LINUX_20void scull_c_release_20(struct inode *ino, struct file *f){    scull_c_release(ino, f);}#define scull_c_release scull_c_release_20#endif/* * The other operations for the device come from the bare device */struct file_operations scull_priv_fops = {    llseek:   scull_llseek,    read:     scull_read,    write:    scull_write,    ioctl:    scull_ioctl,    open:     scull_c_open,    release:  scull_c_release,};/************************************************************************ * * 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;    /* Initialize spinlocks */    spin_lock_init(&scull_s_lock);    spin_lock_init(&scull_u_lock);    spin_lock_init(&scull_w_lock);    spin_lock_init(&scull_c_lock);    /* and semaphores (used by read and write) */    sema_init(&scull_s_device.sem, 1);    sema_init(&scull_u_device.sem, 1);    sema_init(&scull_w_device.sem, 1);    /* and file operations owners */    SET_MODULE_OWNER(&scull_sngl_fops);    SET_MODULE_OWNER(&scull_user_fops);    SET_MODULE_OWNER(&scull_wusr_fops);    SET_MODULE_OWNER(&scull_priv_fops);#ifdef CONFIG_DEVFS_FS    /* finally, create the devfs entry points */    scull_s_device.handle =        devfs_register(scull_devfs_dir, "single",                       DEVFS_FL_AUTO_DEVNUM,                       0, 0, S_IFCHR | S_IRUGO | S_IWUGO,                       &scull_sngl_fops,                       &scull_s_device);    scull_u_device.handle =        devfs_register(scull_devfs_dir, "user",                       DEVFS_FL_AUTO_DEVNUM,                       0, 0, S_IFCHR | S_IRUGO | S_IWUGO,                       &scull_user_fops,                       &scull_u_device);    scull_w_device.handle =        devfs_register(scull_devfs_dir, "wuser",                       DEVFS_FL_AUTO_DEVNUM,                       0, 0, S_IFCHR | S_IRUGO | S_IWUGO,                       &scull_wusr_fops,                       &scull_w_device);    scull_priv_handle =        devfs_register(scull_devfs_dir, "priv",                       DEVFS_FL_AUTO_DEVNUM,                       0, 0, S_IFCHR | S_IRUGO | S_IWUGO,                       &scull_priv_fops,                       &scull_priv_fops); /* any non-null value */#endif        return 0;}/* * This is called by cleanup_module or on failure. * It is required to never fail, even if nothing was initialized first */void scull_access_cleanup(void){    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 */    /* remove devfs entry points */    devfs_unregister(scull_s_device.handle);    devfs_unregister(scull_u_device.handle);    devfs_unregister(scull_w_device.handle);    devfs_unregister(scull_priv_handle);    return;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一本色道亚洲精品aⅴ| 国产精品99久久久久久似苏梦涵 | 亚洲va韩国va欧美va| 日韩影视精彩在线| 国产精品88888| 欧美乱妇一区二区三区不卡视频| 欧美精品99久久久**| 国产人成亚洲第一网站在线播放| 亚洲欧美日韩久久精品| 午夜精品福利在线| av电影在线不卡| 精品国产露脸精彩对白| 亚洲第一久久影院| 91在线一区二区| 久久精品人人做人人综合| 亚洲一区二区影院| 99久久婷婷国产综合精品电影 | 亚洲国产欧美日韩另类综合 | 国产欧美日韩麻豆91| 香蕉加勒比综合久久| 97精品久久久久中文字幕| 日韩精品专区在线影院重磅| 亚洲在线免费播放| 91丨九色porny丨蝌蚪| 国产欧美一区二区精品秋霞影院| 免播放器亚洲一区| 欧美电影影音先锋| 日韩激情一二三区| 亚洲精品一区二区三区福利 | 色偷偷成人一区二区三区91| 久久久国产精品午夜一区ai换脸| 日韩在线a电影| 日韩欧美国产午夜精品| 亚洲成av人片在线观看无码| 欧美日韩视频在线一区二区| 亚洲综合一二区| 91.麻豆视频| 日本午夜精品一区二区三区电影 | av毛片久久久久**hd| 国产精品久久久久桃色tv| 97se亚洲国产综合自在线观| 亚洲日本在线天堂| 欧美人狂配大交3d怪物一区| 免费一区二区视频| 国产精品福利电影一区二区三区四区| 国产精品综合视频| 亚洲影视在线观看| 久久亚洲精华国产精华液 | 天堂一区二区在线免费观看| 日韩视频在线你懂得| 福利一区在线观看| 午夜伦欧美伦电影理论片| 日韩精品中午字幕| 91在线视频播放| 国产真实精品久久二三区| 18成人在线视频| 2021久久国产精品不只是精品| 99国产一区二区三精品乱码| 美女一区二区三区在线观看| 日本一区二区三区电影| 欧美人妇做爰xxxⅹ性高电影| 韩国v欧美v亚洲v日本v| 午夜久久久影院| 亚洲一级在线观看| 国产精品视频九色porn| 国产三级久久久| 精品国产一区二区国模嫣然| 欧美精品777| 91精品欧美久久久久久动漫| 欧美性xxxxx极品少妇| aaa亚洲精品| 91一区二区在线观看| jlzzjlzz国产精品久久| 成人自拍视频在线| 91亚洲资源网| 在线中文字幕一区二区| 91成人在线免费观看| 欧美视频中文字幕| 91精品一区二区三区在线观看| 欧美精品色综合| 日韩欧美视频在线| 久久一夜天堂av一区二区三区| wwwwww.欧美系列| 国产精品嫩草久久久久| 亚洲欧美日韩国产一区二区三区| 国产精品久久久久婷婷二区次| 自拍偷在线精品自拍偷无码专区| 亚洲欧美日韩久久精品| 日韩电影在线观看网站| 韩国一区二区三区| 91丨九色丨黑人外教| 欧美日韩中文一区| 国产亚洲欧美一级| 一区二区在线看| 国产美女在线精品| 在线免费观看日本欧美| 欧美www视频| 亚洲综合色成人| 国产一区二区三区综合| 欧美一激情一区二区三区| 欧美va亚洲va| 一区二区三区免费在线观看| 久久99精品一区二区三区三区| 99视频精品免费视频| 911精品国产一区二区在线| 中文字幕一区av| 黄色日韩三级电影| 欧美日韩二区三区| 亚洲久草在线视频| 成人av网址在线观看| 国产亚洲一区二区三区四区 | 亚洲成人久久影院| 99精品久久99久久久久| 国产精品欧美一区二区三区| 久久精品久久久精品美女| 欧美高清性hdvideosex| 亚洲精品中文在线| 欧美午夜一区二区三区| 亚洲资源中文字幕| 欧美亚男人的天堂| 午夜精品福利久久久| 91精品国产免费久久综合| 爽爽淫人综合网网站| 日韩一区二区高清| 久久精品国产第一区二区三区| av中文字幕在线不卡| 欧美性猛交xxxx乱大交退制版| 制服丝袜日韩国产| 麻豆视频一区二区| 婷婷久久综合九色国产成人| 中文字幕永久在线不卡| 国产午夜一区二区三区| 欧美日本乱大交xxxxx| 91免费看视频| 国产精品综合二区| 久久精品噜噜噜成人av农村| 一色桃子久久精品亚洲| 欧美日韩免费视频| 国产精品中文字幕日韩精品 | 91网站最新网址| 日韩国产精品久久| 亚洲欧洲综合另类| 久久众筹精品私拍模特| 色综合久久综合| 国产精品一区在线观看你懂的| 亚洲精品国产a久久久久久| 亚洲精品在线一区二区| 91精品国产一区二区三区 | 黄色精品一二区| 偷拍一区二区三区| 亚洲欧美日韩国产手机在线| 精品久久久久久久久久久久久久久 | av中文字幕一区| 国产经典欧美精品| 精品一区二区三区日韩| 日日摸夜夜添夜夜添亚洲女人| 中文字幕一区二区不卡 | 欧美刺激午夜性久久久久久久| 99久久免费精品| 国产成人在线视频网址| 麻豆91小视频| 奇米777欧美一区二区| 日本不卡视频在线| 久久99精品国产91久久来源| 久久精品国产精品亚洲综合| 精品一区二区三区免费视频| 久久精品国产99国产精品| 国产一区二区在线免费观看| 国产永久精品大片wwwapp| 成人永久免费视频| 99久久免费国产| 欧美日韩黄色一区二区| 欧美一级艳片视频免费观看| 日韩免费视频线观看| 国产亚洲精品bt天堂精选| 亚洲最新在线观看| 国产资源在线一区| 91免费在线视频观看| 日韩欧美亚洲国产另类| 国产精品久久久久久久岛一牛影视 | 日本亚洲欧美天堂免费| 国产成人日日夜夜| 在线免费观看成人短视频| 国产欧美在线观看一区| 夜夜亚洲天天久久| 国产成人精品亚洲午夜麻豆| 在线视频综合导航| 精品欧美黑人一区二区三区| 欧美国产精品久久| 亚洲成人一区二区| 成人ar影院免费观看视频| 日韩一区二区在线观看视频| 亚洲日本va在线观看| 成人午夜av电影| 久久看人人爽人人| 国产成人综合亚洲91猫咪| 欧美zozozo| 国产91高潮流白浆在线麻豆| 国产日韩欧美不卡| 91在线免费播放|