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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? access.c

?? LINUX設備驅(qū)動2源代碼
?? 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一区二区三区免费野_久草精品视频
国产剧情一区在线| 夜夜夜精品看看| 国产精品一区三区| 精品少妇一区二区三区| 激情欧美日韩一区二区| 精品日韩在线观看| 成人一区二区三区视频| 亚洲欧洲国产日韩| 欧美视频三区在线播放| 久久精品国产77777蜜臀| 久久影音资源网| 99国产精品久久久久久久久久久| 亚洲欧美日韩国产综合在线| 欧美三日本三级三级在线播放| 偷拍亚洲欧洲综合| 精品国产亚洲在线| 91丝袜美女网| 日本美女视频一区二区| 欧美激情在线观看视频免费| 在线免费观看日本欧美| 裸体健美xxxx欧美裸体表演| 久久久精品欧美丰满| 97国产一区二区| 奇米色一区二区三区四区| 国产欧美日韩三级| 欧美日韩一本到| 国产揄拍国内精品对白| 亚洲国产婷婷综合在线精品| 久久先锋资源网| 在线日韩av片| 成人在线综合网站| 亚洲最大色网站| 久久久久久久久岛国免费| 97久久精品人人澡人人爽| 美女久久久精品| 亚洲少妇屁股交4| 欧美一区二区美女| 91视频.com| 国产一区二区久久| 亚洲国产美女搞黄色| 国产三级精品三级在线专区| 欧美精三区欧美精三区| 99久久综合精品| 久久99热这里只有精品| 亚洲成人免费观看| 中文字幕中文乱码欧美一区二区| 日韩视频免费观看高清完整版 | 91久久人澡人人添人人爽欧美| 青青草国产成人99久久| 一区二区在线免费观看| 国产精品色婷婷久久58| 欧美tk—视频vk| 欧美一区二区三区人| 91国偷自产一区二区三区观看| 国产酒店精品激情| 日本成人在线一区| 香蕉成人伊视频在线观看| 综合色中文字幕| 国产精品美女久久久久aⅴ| 亚洲精品一区二区三区99| 91精品啪在线观看国产60岁| 欧美性感一区二区三区| 色偷偷久久人人79超碰人人澡| 懂色av噜噜一区二区三区av| 国产一区二区网址| 黄色成人免费在线| 极品美女销魂一区二区三区免费| 免费人成精品欧美精品| 天涯成人国产亚洲精品一区av| 亚洲精品国产a| 亚洲一区在线观看免费观看电影高清| 国产精品国模大尺度视频| 国产精品理论片| 国产精品婷婷午夜在线观看| 国产亚洲精品aa午夜观看| 国产无一区二区| 中文字幕高清不卡| 亚洲欧洲美洲综合色网| 亚洲黄色性网站| 亚洲国产欧美在线人成| 香蕉乱码成人久久天堂爱免费| 亚洲高清免费在线| 蜜桃视频在线观看一区| 激情图区综合网| 国产98色在线|日韩| 成人黄色软件下载| 色偷偷88欧美精品久久久| 欧美无砖砖区免费| 日韩欧美专区在线| xfplay精品久久| 中文字幕在线观看一区| 亚洲欧美日韩国产综合| 日本中文一区二区三区| 久久99精品国产麻豆不卡| 国产麻豆日韩欧美久久| 99久久久精品免费观看国产蜜| 91激情五月电影| 欧美伦理电影网| 久久中文字幕电影| 亚洲三级在线观看| 蜜臀久久99精品久久久画质超高清| 久久99精品久久久| 99久久亚洲一区二区三区青草 | 蜜臀a∨国产成人精品| 国产在线国偷精品免费看| 99久久精品免费看国产免费软件| 欧美亚洲综合久久| 日韩免费在线观看| 国产精品二三区| 日韩av二区在线播放| 成人免费看的视频| 欧美日韩国产综合一区二区| 精品国产91久久久久久久妲己| 国产精品视频观看| 手机精品视频在线观看| 国产福利一区二区三区在线视频| 色婷婷亚洲综合| 精品999在线播放| 亚洲综合精品自拍| 黄色小说综合网站| 精品视频999| 中文字幕av一区二区三区免费看 | 欧美日韩视频在线一区二区| 精品美女一区二区| 亚洲免费观看高清| 激情av综合网| 7777精品伊人久久久大香线蕉的 | 色婷婷久久久亚洲一区二区三区| 精品日韩在线观看| 午夜天堂影视香蕉久久| 丰满亚洲少妇av| 日韩欧美亚洲另类制服综合在线| 亚洲精品第1页| 成人开心网精品视频| 欧美一级搡bbbb搡bbbb| 亚洲精选免费视频| 成人精品视频.| 久久综合九色综合久久久精品综合| 亚洲一区在线电影| 99免费精品在线| 国产欧美综合在线| 国产中文字幕一区| 欧美一区二区美女| 午夜欧美一区二区三区在线播放| 99久久伊人精品| 国产欧美精品一区二区色综合| 日本欧美一区二区三区乱码| 欧美丝袜丝交足nylons| 中文字幕一区二区三区不卡在线| 国产福利一区二区三区在线视频| 欧美成人精品二区三区99精品| 午夜视频在线观看一区二区三区| 91久久一区二区| 亚洲欧美一区二区三区孕妇| 成人黄色大片在线观看| 欧美韩国一区二区| 国产麻豆一精品一av一免费| www激情久久| 国产精品一二三| 久久免费视频一区| 国产在线国偷精品免费看| 久久先锋影音av| 国产馆精品极品| 亚洲国产激情av| 99精品一区二区三区| 国产精品久久久久婷婷| 不卡的电影网站| 最新日韩av在线| 91国产视频在线观看| 亚洲午夜电影在线观看| 欧美午夜精品久久久久久超碰 | 日本道免费精品一区二区三区| 亚洲久本草在线中文字幕| 在线观看视频欧美| 日韩福利视频网| 日韩欧美中文字幕公布| 国产精品亚洲一区二区三区妖精| 亚洲国产成人自拍| 色综合久久六月婷婷中文字幕| 亚洲日本中文字幕区| 欧美在线观看18| 免费在线观看一区二区三区| 精品久久久久香蕉网| 国产超碰在线一区| **网站欧美大片在线观看| 欧美三级视频在线观看| 欧美a级一区二区| 国产欧美日本一区二区三区| 99久久99久久精品免费看蜜桃| 亚洲一区在线观看视频| 日韩免费观看高清完整版| 成人免费va视频| 亚洲成人综合网站| 久久一日本道色综合| 99久久国产综合色|国产精品| 亚洲成人av资源| 国产免费成人在线视频| 欧美伊人久久久久久久久影院| 久久精品国产99| 亚洲视频一区在线观看|