summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Martinez Canillas <martinez.javier@gmail.com>2010-11-28 01:26:07 +0100
committerJavier Martinez Canillas <martinez.javier@gmail.com>2010-11-28 01:26:07 +0100
commit12e0c15fe322f27ac8f3fc784f09a10c0a35ec28 (patch)
tree4b4e0e8038b96c6e142ca19f4bf27342f4dbc7f2
parent1ad0ec43e5985aab09dd03cf92dfa7b2fda7444e (diff)
downloadldd3-12e0c15fe322f27ac8f3fc784f09a10c0a35ec28.tar.gz
scull: access: Fix headers and use current_uid() and current_euid() macros
-rw-r--r--scull/access.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/scull/access.c b/scull/access.c
index 970b57c..b534721 100644
--- a/scull/access.c
+++ b/scull/access.c
@@ -28,6 +28,8 @@
#include <linux/tty.h>
#include <asm/atomic.h>
#include <linux/list.h>
+#include <linux/cred.h> /* current_uid(), current_euid() */
+#include <linux/sched.h>
#include "scull.h" /* local definitions */
@@ -103,15 +105,15 @@ static int scull_u_open(struct inode *inode, struct file *filp)
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 */
+ (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_owner = current_uid(); /* grab it */
scull_u_count++;
spin_unlock(&scull_u_lock);
@@ -162,8 +164,8 @@ static spinlock_t scull_w_lock = SPIN_LOCK_UNLOCKED;
static inline int scull_w_available(void)
{
return scull_w_count == 0 ||
- scull_w_owner == current->uid ||
- scull_w_owner == current->euid ||
+ scull_w_owner == current_uid() ||
+ scull_w_owner == current_euid() ||
capable(CAP_DAC_OVERRIDE);
}
@@ -181,7 +183,7 @@ static int scull_w_open(struct inode *inode, struct file *filp)
spin_lock(&scull_w_lock);
}
if (scull_w_count == 0)
- scull_w_owner = current->uid; /* grab it */
+ scull_w_owner = current_uid(); /* grab it */
scull_w_count++;
spin_unlock(&scull_w_lock);