[Ocfs2-commits] jlbec commits r1930 - trunk/fs/usysfs
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Mar 1 20:35:13 CST 2005
Author: jlbec
Signed-off-by: mfasheh
Date: 2005-03-01 20:35:11 -0600 (Tue, 01 Mar 2005)
New Revision: 1930
Modified:
trunk/fs/usysfs/symlink.c
Log:
o Commit the symlink code I have so far, so that others can work on it.
Signed-off-by: mfasheh
Modified: trunk/fs/usysfs/symlink.c
===================================================================
--- trunk/fs/usysfs/symlink.c 2005-03-02 02:24:30 UTC (rev 1929)
+++ trunk/fs/usysfs/symlink.c 2005-03-02 02:35:11 UTC (rev 1930)
@@ -1,4 +1,6 @@
-/*
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
* symlink.c - operations for usysfs symlinks.
*/
@@ -95,6 +97,53 @@
}
+int usysfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
+{
+ int ret;
+ struct nameidata nd;
+ struct kobject *parent_kobj;
+ struct kobject *target_kobj;
+ struct ukobj_type *uktype;
+
+ if (dentry->d_parent == usysfs_sb->s_root)
+ return -EPERM;
+
+ parent_kobj = usysfs_get_kobject(dentry->d_parent);
+ uktype = to_uktype(parent_kobj->ktype);
+
+ if (!uktype || !uktype->allow_link) {
+ kobject_put(parent_kobj);
+ return -EPERM; /* What lack-of-symlink returns */
+ }
+
+ ret = path_lookup(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
+ if (ret) {
+ kobject_put(parent_kobj);
+ return ret;
+ }
+
+ ret = -ENOENT;
+ target_kobj = usysfs_get_kobject(nd.dentry);
+ if (!target_kobj)
+ goto out_release;
+
+ ret = uktype->allow_link(parent_kobj, target_kobj);
+ if (ret)
+ goto out_target;
+
+ return 0;
+
+out_target:
+ kobject_put(target_kobj);
+
+out_release:
+ path_release(&nd);
+
+ kobject_put(parent_kobj);
+
+ return ret;
+}
+
/**
* usysfs_remove_link - remove symlink in object's directory.
* @kobj: object we're acting for.
More information about the Ocfs2-commits
mailing list