drm/radeon/kms: add hw_i2c module option
[linux-2.6.git] / fs / dcookies.c
index 855d4b1..a21cabd 100644 (file)
@@ -93,10 +93,15 @@ static struct dcookie_struct *alloc_dcookie(struct path *path)
 {
        struct dcookie_struct *dcs = kmem_cache_alloc(dcookie_cache,
                                                        GFP_KERNEL);
+       struct dentry *d;
        if (!dcs)
                return NULL;
 
-       path->dentry->d_cookie = dcs;
+       d = path->dentry;
+       spin_lock(&d->d_lock);
+       d->d_flags |= DCACHE_COOKIE;
+       spin_unlock(&d->d_lock);
+
        dcs->path = *path;
        path_get(path);
        hash_dcookie(dcs);
@@ -119,14 +124,14 @@ int get_dcookie(struct path *path, unsigned long *cookie)
                goto out;
        }
 
-       dcs = path->dentry->d_cookie;
-
-       if (!dcs)
+       if (path->dentry->d_flags & DCACHE_COOKIE) {
+               dcs = find_dcookie((unsigned long)path->dentry);
+       } else {
                dcs = alloc_dcookie(path);
-
-       if (!dcs) {
-               err = -ENOMEM;
-               goto out;
+               if (!dcs) {
+                       err = -ENOMEM;
+                       goto out;
+               }
        }
 
        *cookie = dcookie_value(dcs);
@@ -140,7 +145,7 @@ out:
 /* And here is where the userspace process can look up the cookie value
  * to retrieve the path.
  */
-asmlinkage long sys_lookup_dcookie(u64 cookie64, char __user * buf, size_t len)
+SYSCALL_DEFINE(lookup_dcookie)(u64 cookie64, char __user * buf, size_t len)
 {
        unsigned long cookie = (unsigned long)cookie64;
        int err = -EINVAL;
@@ -193,7 +198,13 @@ out:
        mutex_unlock(&dcookie_mutex);
        return err;
 }
-
+#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
+asmlinkage long SyS_lookup_dcookie(u64 cookie64, long buf, long len)
+{
+       return SYSC_lookup_dcookie(cookie64, (char __user *) buf, (size_t) len);
+}
+SYSCALL_ALIAS(sys_lookup_dcookie, SyS_lookup_dcookie);
+#endif
 
 static int dcookie_init(void)
 {
@@ -251,7 +262,12 @@ out_kmem:
 
 static void free_dcookie(struct dcookie_struct * dcs)
 {
-       dcs->path.dentry->d_cookie = NULL;
+       struct dentry *d = dcs->path.dentry;
+
+       spin_lock(&d->d_lock);
+       d->d_flags &= ~DCACHE_COOKIE;
+       spin_unlock(&d->d_lock);
+
        path_put(&dcs->path);
        kmem_cache_free(dcookie_cache, dcs);
 }