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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [fs/] [autofs/] [symlink.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1628 jcastillo
/* -*- linux-c -*- --------------------------------------------------------- *
2
 *
3
 * linux/fs/autofs/symlink.c
4
 *
5
 *  Copyright 1997 Transmeta Corporation -- All Rights Reserved
6
 *
7
 * This file is part of the Linux kernel and is made available under
8
 * the terms of the GNU General Public License, version 2, or at your
9
 * option, any later version, incorporated herein by reference.
10
 *
11
 * ------------------------------------------------------------------------- */
12
 
13
#include <linux/string.h>
14
#include <linux/sched.h>
15
#include "autofs_i.h"
16
 
17
static int autofs_follow_link(struct inode *dir, struct inode *inode,
18
                              int flag, int mode, struct inode **res_inode)
19
{
20
        int error;
21
        char *link;
22
 
23
        *res_inode = NULL;
24
        if (!dir) {
25
                dir = current->fs->root;
26
                dir->i_count++;
27
        }
28
        if (!inode) {
29
                iput(dir);
30
                return -ENOENT;
31
        }
32
        if (!S_ISLNK(inode->i_mode)) {
33
                iput(dir);
34
                *res_inode = inode;
35
                return 0;
36
        }
37
        if (current->link_count > 5) {
38
                iput(dir);
39
                iput(inode);
40
                return -ELOOP;
41
        }
42
        link = ((struct autofs_symlink *)inode->u.generic_ip)->data;
43
        current->link_count++;
44
        error = open_namei(link,flag,mode,res_inode,dir);
45
        current->link_count--;
46
        iput(inode);
47
        return error;
48
}
49
 
50
static int autofs_readlink(struct inode *inode, char *buffer, int buflen)
51
{
52
        struct autofs_symlink *sl;
53
        int len;
54
 
55
        if (!S_ISLNK(inode->i_mode)) {
56
                iput(inode);
57
                return -EINVAL;
58
        }
59
        sl = (struct autofs_symlink *)inode->u.generic_ip;
60
        len = sl->len;
61
        if (len > buflen) len = buflen;
62
        copy_to_user(buffer,sl->data,len);
63
        iput(inode);
64
        return len;
65
}
66
 
67
struct inode_operations autofs_symlink_inode_operations = {
68
        NULL,                   /* file operations */
69
        NULL,                   /* create */
70
        NULL,                   /* lookup */
71
        NULL,                   /* link */
72
        NULL,                   /* unlink */
73
        NULL,                   /* symlink */
74
        NULL,                   /* mkdir */
75
        NULL,                   /* rmdir */
76
        NULL,                   /* mknod */
77
        NULL,                   /* rename */
78
        autofs_readlink,        /* readlink */
79
        autofs_follow_link,     /* follow_link */
80
        NULL,                   /* readpage */
81
        NULL,                   /* writepage */
82
        NULL,                   /* bmap */
83
        NULL,                   /* truncate */
84
        NULL                    /* permission */
85
};

powered by: WebSVN 2.1.0

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