当前位置: 技术问答>linux和unix
linux device driver scull sample code問題
来源: 互联网 发布时间:2016-03-24
本文导语: make 問題(在kernel 2.6.24-1下編譯) 其中一段錯誤 4 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c: In function 'scull_u_open': 5 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:114: error: dereferencing pointer to incomplete type ...
make 問題(在kernel 2.6.24-1下編譯)
其中一段錯誤
4 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c: In function 'scull_u_open':
5 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:114: error: dereferencing pointer to incomplete type
6 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c: In function 'scull_w_available':
7 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:165: error: dereferencing pointer to incomplete type
8 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:166: error: dereferencing pointer to incomplete
9 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c: In function 'scull_w_open':
10 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:179: error: 'TASK_INTERRUPTIBLE' undeclared (first use in this function)
11 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:179: error: (Each undeclared identifier is reported only once
source code:
100 static int scull_u_open(struct inode *inode, struct file *filp)
101 { 102 struct scull_dev *dev = &scull_u_device; /* device information */
103 spin_lock(&scull_u_lock); 104 if (scull_u_count &&
105 (scull_u_owner != current->uid) && /* allow user */ 106 (scull_u_owner != current->euid) && /* allow whoever did su */
107 !capable(CAP_DAC_OVERRIDE)) { /* still allow root */ 108 spin_unlock(&scull_u_lock);
109 return -EBUSY; /* -EPERM would confuse the user */
110 } 111 if (scull_u_count == 0)
112 scull_u_owner = current->uid; /* grab it */
113 114 scull_u_count++;
115 spin_unlock(&scull_u_lock); 116
117 /* then, everything else is copied from the bare scull device */
118
119 if ((filp->f_flags & O_ACCMODE) == O_WRONLY)
120 scull_trim(dev);
121 filp->private_data = dev;
122 return 0; /* success */
123 }
請問current這個變數是從何而來的
其中一段錯誤
4 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c: In function 'scull_u_open':
5 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:114: error: dereferencing pointer to incomplete type
6 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c: In function 'scull_w_available':
7 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:165: error: dereferencing pointer to incomplete type
8 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:166: error: dereferencing pointer to incomplete
9 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c: In function 'scull_w_open':
10 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:179: error: 'TASK_INTERRUPTIBLE' undeclared (first use in this function)
11 /mnt/200GB/MyShare2/LDD3/examples/scull/access.c:179: error: (Each undeclared identifier is reported only once
source code:
100 static int scull_u_open(struct inode *inode, struct file *filp)
101 { 102 struct scull_dev *dev = &scull_u_device; /* device information */
103 spin_lock(&scull_u_lock); 104 if (scull_u_count &&
105 (scull_u_owner != current->uid) && /* allow user */ 106 (scull_u_owner != current->euid) && /* allow whoever did su */
107 !capable(CAP_DAC_OVERRIDE)) { /* still allow root */ 108 spin_unlock(&scull_u_lock);
109 return -EBUSY; /* -EPERM would confuse the user */
110 } 111 if (scull_u_count == 0)
112 scull_u_owner = current->uid; /* grab it */
113 114 scull_u_count++;
115 spin_unlock(&scull_u_lock); 116
117 /* then, everything else is copied from the bare scull device */
118
119 if ((filp->f_flags & O_ACCMODE) == O_WRONLY)
120 scull_trim(dev);
121 filp->private_data = dev;
122 return 0; /* success */
123 }
請問current這個變數是從何而來的
|
这里有解答:
http://moto.debian.org.tw/viewtopic.php?t=12771&sid=668bb12897de39cfa6468a8f5dfdff74
http://moto.debian.org.tw/viewtopic.php?t=12771&sid=668bb12897de39cfa6468a8f5dfdff74
|
current从kernel来,它代表当前运行进程的task_struct