summaryrefslogtreecommitdiffstats
path: root/fs/autofs/symlink.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-04-29 21:13:14 +0000
committer <ralf@linux-mips.org>1997-04-29 21:13:14 +0000
commit19c9bba94152148523ba0f7ef7cffe3d45656b11 (patch)
tree40b1cb534496a7f1ca0f5c314a523c69f1fee464 /fs/autofs/symlink.c
parent7206675c40394c78a90e74812bbdbf8cf3cca1be (diff)
Import of Linux/MIPS 2.1.36
Diffstat (limited to 'fs/autofs/symlink.c')
-rw-r--r--fs/autofs/symlink.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/fs/autofs/symlink.c b/fs/autofs/symlink.c
new file mode 100644
index 000000000..0e932c169
--- /dev/null
+++ b/fs/autofs/symlink.c
@@ -0,0 +1,85 @@
+/* -*- linux-c -*- --------------------------------------------------------- *
+ *
+ * linux/fs/autofs/symlink.c
+ *
+ * Copyright 1997 Transmeta Corporation -- All Rights Reserved
+ *
+ * This file is part of the Linux kernel and is made available under
+ * the terms of the GNU General Public License, version 2, or at your
+ * option, any later version, incorporated herein by reference.
+ *
+ * ------------------------------------------------------------------------- */
+
+#include <linux/string.h>
+#include <linux/sched.h>
+#include <linux/auto_fs.h>
+
+static int autofs_follow_link(struct inode *dir, struct inode *inode,
+ int flag, int mode, struct inode **res_inode)
+{
+ int error;
+ char *link;
+
+ *res_inode = NULL;
+ if (!dir) {
+ dir = current->fs->root;
+ dir->i_count++;
+ }
+ if (!inode) {
+ iput(dir);
+ return -ENOENT;
+ }
+ if (!S_ISLNK(inode->i_mode)) {
+ iput(dir);
+ *res_inode = inode;
+ return 0;
+ }
+ if (current->link_count > 5) {
+ iput(dir);
+ iput(inode);
+ return -ELOOP;
+ }
+ link = ((struct autofs_symlink *)inode->u.generic_ip)->data;
+ current->link_count++;
+ error = open_namei(link,flag,mode,res_inode,dir);
+ current->link_count--;
+ iput(inode);
+ return error;
+}
+
+static int autofs_readlink(struct inode *inode, char *buffer, int buflen)
+{
+ struct autofs_symlink *sl;
+ int len;
+
+ if (!S_ISLNK(inode->i_mode)) {
+ iput(inode);
+ return -EINVAL;
+ }
+ sl = (struct autofs_symlink *)inode->u.generic_ip;
+ len = sl->len;
+ if (len > buflen) len = buflen;
+ copy_to_user(buffer,sl->data,len);
+ iput(inode);
+ return len;
+}
+
+struct inode_operations autofs_symlink_inode_operations = {
+ NULL, /* file operations */
+ NULL, /* create */
+ NULL, /* lookup */
+ NULL, /* link */
+ NULL, /* unlink */
+ NULL, /* symlink */
+ NULL, /* mkdir */
+ NULL, /* rmdir */
+ NULL, /* mknod */
+ NULL, /* rename */
+ autofs_readlink, /* readlink */
+ autofs_follow_link, /* follow_link */
+ NULL, /* readpage */
+ NULL, /* writepage */
+ NULL, /* bmap */
+ NULL, /* truncate */
+ NULL /* permission */
+};