- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
static void module3_exit(void){
cdev_del(mydev);
printk(KERN_INFO"Device"DEV_NAME"was deleted");
};
int mydev_open(struct inode *in,struct file *filp){
printk(KERN_INFO DEV_NAME "open");
struct dev_state *dev_stat;
dev_stat=&STATE[MINOR(in->i_rdev)];
if(dev_stat->dev_open)
{
printk("Kernel: device "DEV_NAME" is exist");
return -EBUSY;
};
dev_stat->dev_open++;
dev_stat->dev_read=0;
dev_stat->dev_write=0;
int num= NUM(in->i_rdev);
int type=TYPE(in->i_rdev);
return 0;
};
int mydev_ioctl(struct inode *in,struct file *filp,unsigned int ioctl,unsigned long param)
{
printk(KERN_INFO DEV_NAME "ioctl");
return 0;
};
ssize_t mydev_read(struct file *filp,char *buff,ssize_t len,loff_t pos)
{
printk(KERN_INFO DEV_NAME "read");
struct inode *in;
int count=len;
struct dev_state *devst;
printk("Kernel: try to read %d bytes \n",len);
in=filp->f_dentry->d_inode;
printk("Kernel: minor number is %d",MINOR(in->i_rdev));
devst=&STATE[MINOR(in->i_rdev)];
while(count--)
{
put_user(inb_p(PORT_START+10*MINOR(in->i_rdev)),buff);
buff++;
};
devst->dev_read+=len;
printk(KERN_INFO"Kernel: read "DEV_NAME" %d bytes",len);
return len;
};
ssize_t mydev_write(struct file *filp, const char *buff, ssize_t len,loff_t pos)
{
printk(KERN_INFO DEV_NAME "write");
struct inode *in;
int count=len;
unsigned char byte;
struct dev_state *devst;
printk(KERN_INFO"Kernel: try to write %d bytes\n",len);
in=filp->f_dentry->d_inode;
printk(KERN_INFO"Kernel: minor number %d\n",MINOR(in->i_rdev));
devst=&STATE[MINOR(in->i_rdev)];
while(count--)
{
get_user(byte, buff);
outb_p(byte, PORT_START+10*MINOR(in->i_rdev));
buff++;
};
devst->dev_write +=len;
printk(KERN_INFO"Kernel: "DEV_NAME " written %d bytes\n",len);
return len;
};
guest 25.12.2009 16:06 # 0
guest 25.12.2009 16:09 # 0
apple-way 25.12.2009 16:35 # 0
guest 25.12.2009 17:36 # +1
guest 25.12.2009 20:28 # −1
guest 26.12.2009 10:36 # 0
4cppMan 29.12.2009 01:39 # 0
Пару энторов людям влом вставить между логическими частями. Жалко места
4cppMan 29.12.2009 01:40 # 0
4cppMan 29.12.2009 01:42 # 0
Индус писал короче
Alice 29.12.2009 13:51 # 0
guest 31.12.2009 13:39 # 0
guest 20.01.2010 19:06 # 0
Говногость 21.01.2010 01:08 # 0
int type=TYPE(in->i_rdev);
return 0;
А смысл производить присвоение, если выходишь из функции?..
Говногость 21.01.2010 01:09 # 0