OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [before_ORP/] [uclinux/] [uClinux-2.0.x/] [fs/] [isofs/] [symlink.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 *  linux/fs/isofs/symlink.c
3
 *
4
 *  (C) 1992  Eric Youngdale Modified for ISO9660 filesystem.
5
 *
6
 *  Copyright (C) 1991, 1992  Linus Torvalds
7
 *
8
 *  isofs symlink handling code.  This is only used with the Rock Ridge
9
 *  extensions to iso9660
10
 */
11
 
12
#include <linux/errno.h>
13
#include <linux/sched.h>
14
#include <linux/fs.h>
15
#include <linux/iso_fs.h>
16
#include <linux/stat.h>
17
#include <linux/malloc.h>
18
 
19
#include <asm/segment.h>
20
 
21
static int isofs_readlink(struct inode *, char *, int);
22
static int isofs_follow_link(struct inode *, struct inode *, int, int, struct inode **);
23
 
24
/*
25
 * symlinks can't do much...
26
 */
27
struct inode_operations isofs_symlink_inode_operations = {
28
        NULL,                   /* no file-operations */
29
        NULL,                   /* create */
30
        NULL,                   /* lookup */
31
        NULL,                   /* link */
32
        NULL,                   /* unlink */
33
        NULL,                   /* symlink */
34
        NULL,                   /* mkdir */
35
        NULL,                   /* rmdir */
36
        NULL,                   /* mknod */
37
        NULL,                   /* rename */
38
        isofs_readlink,         /* readlink */
39
        isofs_follow_link,      /* follow_link */
40
        NULL,                   /* readpage */
41
        NULL,                   /* writepage */
42
        NULL,                   /* bmap */
43
        NULL,                   /* truncate */
44
        NULL                    /* permission */
45
};
46
 
47
static int isofs_follow_link(struct inode * dir, struct inode * inode,
48
        int flag, int mode, struct inode ** res_inode)
49
{
50
        int error;
51
        char * pnt;
52
 
53
        if (!dir) {
54
                dir = current->fs->root;
55
                dir->i_count++;
56
        }
57
        if (!inode) {
58
                iput(dir);
59
                *res_inode = NULL;
60
                return -ENOENT;
61
        }
62
        if (!S_ISLNK(inode->i_mode)) {
63
                iput(dir);
64
                *res_inode = inode;
65
                return 0;
66
        }
67
        if ((current->link_count > 5) ||
68
           !(pnt = get_rock_ridge_symlink(inode))) {
69
                iput(dir);
70
                iput(inode);
71
                *res_inode = NULL;
72
                return -ELOOP;
73
        }
74
        iput(inode);
75
        current->link_count++;
76
        error = open_namei(pnt,flag,mode,res_inode,dir);
77
        current->link_count--;
78
        kfree(pnt);
79
        return error;
80
}
81
 
82
static int isofs_readlink(struct inode * inode, char * buffer, int buflen)
83
{
84
        char * pnt;
85
        int i;
86
        char c;
87
 
88
        if (!S_ISLNK(inode->i_mode)) {
89
                iput(inode);
90
                return -EINVAL;
91
        }
92
 
93
        if (buflen > 1023)
94
                buflen = 1023;
95
        pnt = get_rock_ridge_symlink(inode);
96
 
97
        iput(inode);
98
        if (!pnt)
99
                return 0;
100
        i = 0;
101
 
102
        while (i<buflen && (c = pnt[i])) {
103
                i++;
104
                put_user(c,buffer++);
105
        }
106
        kfree(pnt);
107
        return i;
108
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.