Import 2.2.7
[davej-history.git] / fs / qnx4 / symlinks.c
blob083042d711d6d2d5cc46a68bd915c7425d6aa982
1 /*
2 * QNX4 file system, Linux implementation.
3 *
4 * Version : 0.1
5 *
6 * Using parts of the xiafs filesystem.
7 *
8 * History :
9 *
10 * 28-05-1998 by Richard Frowijn : first release.
11 * 21-06-1998 by Frank Denis : ugly changes to make it compile on Linux 2.1.99+
14 /* THIS FILE HAS TO BE REWRITTEN */
16 #include <linux/errno.h>
17 #include <linux/sched.h>
18 #include <linux/fs.h>
19 #include <linux/qnx4_fs.h>
20 #include <linux/stat.h>
22 #include <asm/segment.h>
23 #include <asm/uaccess.h>
25 static int qnx4_readlink(struct dentry *, char *, int);
26 static struct dentry *qnx4_follow_link(struct dentry *, struct dentry *, unsigned int follow);
29 * symlinks can't do much...
31 struct inode_operations qnx4_symlink_inode_operations =
33 NULL, /* no file-operations */
34 NULL, /* create */
35 NULL, /* lookup */
36 NULL, /* link */
37 NULL, /* unlink */
38 NULL, /* symlink */
39 NULL, /* mkdir */
40 NULL, /* rmdir */
41 NULL, /* mknod */
42 NULL, /* rename */
43 qnx4_readlink, /* readlink */
44 qnx4_follow_link, /* follow_link */
45 NULL, /* readpage */
46 NULL, /* writepage */
47 NULL, /* bmap */
48 NULL, /* truncate */
49 NULL /* permission */
52 static struct dentry *qnx4_follow_link(struct dentry *dentry,
53 struct dentry *base, unsigned int follow)
55 #if 0
56 struct inode *inode = dentry->d_inode;
57 struct buffer_head *bh;
59 if (!inode) {
60 return ERR_PTR(-ENOENT);
62 if (current->link_count > 5) {
63 return ERR_PTR(-ELOOP);
65 if (!(bh = qnx4_bread(inode, 0, 0))) {
66 return ERR_PTR(-EIO);
68 current->link_count++;
69 current->link_count--;
70 brelse(bh);
71 return 0;
72 #else
73 printk("qnx4: qnx4_follow_link needs to be fixed.\n");
74 return ERR_PTR(-EIO);
75 #endif
78 static int qnx4_readlink(struct dentry *dentry, char *buffer, int buflen)
80 struct inode *inode = dentry->d_inode;
81 struct buffer_head *bh;
82 int i;
83 char c;
84 struct qnx4_inode_info *qnx4_ino;
86 QNX4DEBUG(("qnx4: qnx4_readlink() called\n"));
88 if (buffer == NULL || inode == NULL || !S_ISLNK(inode->i_mode)) {
89 return -EINVAL;
91 qnx4_ino = &inode->u.qnx4_i;
92 if (buflen > 1023) {
93 buflen = 1023;
95 bh = bread(inode->i_dev, qnx4_ino->i_first_xtnt.xtnt_blk,
96 QNX4_BLOCK_SIZE);
97 QNX4DEBUG(("qnx4: qnx4_bread sym called -> [%s]\n",
98 bh->b_data));
99 if (bh == NULL) {
100 QNX4DEBUG(("qnx4: NULL symlink bh\n"));
101 return 0;
103 if (bh->b_data[0] != 0) {
104 i = 0;
105 while (i < buflen && (c = bh->b_data[i])) {
106 i++;
107 put_user(c, buffer++);
109 brelse(bh);
110 return i;
111 } else {
112 brelse(bh);
113 memcpy(buffer, "fixme", 5);
114 return 5;