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] - Diff between revs 901 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 901 Rev 1765
/*
/*
 *  linux/fs/isofs/symlink.c
 *  linux/fs/isofs/symlink.c
 *
 *
 *  (C) 1992  Eric Youngdale Modified for ISO9660 filesystem.
 *  (C) 1992  Eric Youngdale Modified for ISO9660 filesystem.
 *
 *
 *  Copyright (C) 1991, 1992  Linus Torvalds
 *  Copyright (C) 1991, 1992  Linus Torvalds
 *
 *
 *  isofs symlink handling code.  This is only used with the Rock Ridge
 *  isofs symlink handling code.  This is only used with the Rock Ridge
 *  extensions to iso9660
 *  extensions to iso9660
 */
 */
 
 
#include <linux/errno.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/fs.h>
#include <linux/iso_fs.h>
#include <linux/iso_fs.h>
#include <linux/stat.h>
#include <linux/stat.h>
#include <linux/malloc.h>
#include <linux/malloc.h>
 
 
#include <asm/segment.h>
#include <asm/segment.h>
 
 
static int isofs_readlink(struct inode *, char *, int);
static int isofs_readlink(struct inode *, char *, int);
static int isofs_follow_link(struct inode *, struct inode *, int, int, struct inode **);
static int isofs_follow_link(struct inode *, struct inode *, int, int, struct inode **);
 
 
/*
/*
 * symlinks can't do much...
 * symlinks can't do much...
 */
 */
struct inode_operations isofs_symlink_inode_operations = {
struct inode_operations isofs_symlink_inode_operations = {
        NULL,                   /* no file-operations */
        NULL,                   /* no file-operations */
        NULL,                   /* create */
        NULL,                   /* create */
        NULL,                   /* lookup */
        NULL,                   /* lookup */
        NULL,                   /* link */
        NULL,                   /* link */
        NULL,                   /* unlink */
        NULL,                   /* unlink */
        NULL,                   /* symlink */
        NULL,                   /* symlink */
        NULL,                   /* mkdir */
        NULL,                   /* mkdir */
        NULL,                   /* rmdir */
        NULL,                   /* rmdir */
        NULL,                   /* mknod */
        NULL,                   /* mknod */
        NULL,                   /* rename */
        NULL,                   /* rename */
        isofs_readlink,         /* readlink */
        isofs_readlink,         /* readlink */
        isofs_follow_link,      /* follow_link */
        isofs_follow_link,      /* follow_link */
        NULL,                   /* readpage */
        NULL,                   /* readpage */
        NULL,                   /* writepage */
        NULL,                   /* writepage */
        NULL,                   /* bmap */
        NULL,                   /* bmap */
        NULL,                   /* truncate */
        NULL,                   /* truncate */
        NULL                    /* permission */
        NULL                    /* permission */
};
};
 
 
static int isofs_follow_link(struct inode * dir, struct inode * inode,
static int isofs_follow_link(struct inode * dir, struct inode * inode,
        int flag, int mode, struct inode ** res_inode)
        int flag, int mode, struct inode ** res_inode)
{
{
        int error;
        int error;
        char * pnt;
        char * pnt;
 
 
        if (!dir) {
        if (!dir) {
                dir = current->fs->root;
                dir = current->fs->root;
                dir->i_count++;
                dir->i_count++;
        }
        }
        if (!inode) {
        if (!inode) {
                iput(dir);
                iput(dir);
                *res_inode = NULL;
                *res_inode = NULL;
                return -ENOENT;
                return -ENOENT;
        }
        }
        if (!S_ISLNK(inode->i_mode)) {
        if (!S_ISLNK(inode->i_mode)) {
                iput(dir);
                iput(dir);
                *res_inode = inode;
                *res_inode = inode;
                return 0;
                return 0;
        }
        }
        if ((current->link_count > 5) ||
        if ((current->link_count > 5) ||
           !(pnt = get_rock_ridge_symlink(inode))) {
           !(pnt = get_rock_ridge_symlink(inode))) {
                iput(dir);
                iput(dir);
                iput(inode);
                iput(inode);
                *res_inode = NULL;
                *res_inode = NULL;
                return -ELOOP;
                return -ELOOP;
        }
        }
        iput(inode);
        iput(inode);
        current->link_count++;
        current->link_count++;
        error = open_namei(pnt,flag,mode,res_inode,dir);
        error = open_namei(pnt,flag,mode,res_inode,dir);
        current->link_count--;
        current->link_count--;
        kfree(pnt);
        kfree(pnt);
        return error;
        return error;
}
}
 
 
static int isofs_readlink(struct inode * inode, char * buffer, int buflen)
static int isofs_readlink(struct inode * inode, char * buffer, int buflen)
{
{
        char * pnt;
        char * pnt;
        int i;
        int i;
        char c;
        char c;
 
 
        if (!S_ISLNK(inode->i_mode)) {
        if (!S_ISLNK(inode->i_mode)) {
                iput(inode);
                iput(inode);
                return -EINVAL;
                return -EINVAL;
        }
        }
 
 
        if (buflen > 1023)
        if (buflen > 1023)
                buflen = 1023;
                buflen = 1023;
        pnt = get_rock_ridge_symlink(inode);
        pnt = get_rock_ridge_symlink(inode);
 
 
        iput(inode);
        iput(inode);
        if (!pnt)
        if (!pnt)
                return 0;
                return 0;
        i = 0;
        i = 0;
 
 
        while (i<buflen && (c = pnt[i])) {
        while (i<buflen && (c = pnt[i])) {
                i++;
                i++;
                put_user(c,buffer++);
                put_user(c,buffer++);
        }
        }
        kfree(pnt);
        kfree(pnt);
        return i;
        return i;
}
}
 
 

powered by: WebSVN 2.1.0

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