2 * linux/fs/xiafs/symlink.c
4 * Copyright (C) Q. Frank Xia, 1993.
6 * Based on Linus' minix/symlink.c
7 * Copyright (C) Linus Torvalds, 1991, 1992.
9 * This software may be redistributed per Linux Copyright.
12 #include <asm/segment.h>
14 #include <linux/errno.h>
15 #include <linux/sched.h>
17 #include <linux/xia_fs.h>
18 #include <linux/stat.h>
21 xiafs_readlink(struct inode
*, char *, int);
24 xiafs_follow_link(struct inode
*, struct inode
*, int, int, struct inode
**);
27 * symlinks can't do much...
29 struct inode_operations xiafs_symlink_inode_operations
= {
30 NULL
, /* no file-operations */
40 xiafs_readlink
, /* readlink */
41 xiafs_follow_link
, /* follow_link */
47 static int xiafs_readlink(struct inode
* inode
, char * buffer
, int buflen
)
49 struct buffer_head
* bh
;
53 if (!S_ISLNK(inode
->i_mode
)) {
57 if (buflen
> BLOCK_SIZE
)
59 bh
= xiafs_bread(inode
, 0, 0);
60 if (!IS_RDONLY (inode
)) {
61 inode
->i_atime
=CURRENT_TIME
;
67 for (i
=0; i
< buflen
&& (c
=bh
->b_data
[i
]); i
++)
68 put_fs_byte(c
, buffer
++);
70 put_fs_byte((char)0, buffer
);
75 static int xiafs_follow_link(struct inode
* dir
, struct inode
* inode
,
76 int flag
, int mode
, struct inode
** res_inode
)
79 struct buffer_head
* bh
;
90 if (!S_ISLNK(inode
->i_mode
)) {
95 if (!IS_RDONLY (inode
)) {
96 inode
->i_atime
=CURRENT_TIME
;
99 if (current
->link_count
> 5) {
104 if (!(bh
= xiafs_bread(inode
, 0, 0))) {
110 current
->link_count
++;
111 error
= open_namei(bh
->b_data
,flag
,mode
,res_inode
,dir
);
112 current
->link_count
--;