root/fs/isofs/symlink.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. isofs_follow_link
  2. isofs_readlink

   1 /*
   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 <asm/segment.h>
  13 
  14 #include <linux/errno.h>
  15 #include <linux/sched.h>
  16 #include <linux/fs.h>
  17 #include <linux/iso_fs.h>
  18 #include <linux/stat.h>
  19 
  20 static int isofs_readlink(struct inode *, char *, int);
  21 static int isofs_follow_link(struct inode *, struct inode *, int, int, struct inode **);
  22 
  23 /*
  24  * symlinks can't do much...
  25  */
  26 struct inode_operations isofs_symlink_inode_operations = {
  27         NULL,                   /* no file-operations */
  28         NULL,                   /* create */
  29         NULL,                   /* lookup */
  30         NULL,                   /* link */
  31         NULL,                   /* unlink */
  32         NULL,                   /* symlink */
  33         NULL,                   /* mkdir */
  34         NULL,                   /* rmdir */
  35         NULL,                   /* mknod */
  36         NULL,                   /* rename */
  37         isofs_readlink,         /* readlink */
  38         isofs_follow_link,      /* follow_link */
  39         NULL,                   /* bmap */
  40         NULL                    /* truncate */
  41 };
  42 
  43 static int isofs_follow_link(struct inode * dir, struct inode * inode,
     /* [previous][next][first][last][top][bottom][index][help] */
  44         int flag, int mode, struct inode ** res_inode)
  45 {
  46         int error;
  47         unsigned short fs;
  48         char * pnt;
  49 
  50         if (!dir) {
  51                 dir = current->root;
  52                 dir->i_count++;
  53         }
  54         if (!inode) {
  55                 iput(dir);
  56                 *res_inode = NULL;
  57                 return -ENOENT;
  58         }
  59         if (!S_ISLNK(inode->i_mode)) {
  60                 iput(dir);
  61                 *res_inode = inode;
  62                 return 0;
  63         }
  64         __asm__("mov %%fs,%0":"=r" (fs));
  65         if ((current->link_count > 5) ||
  66            !(pnt = get_rock_ridge_symlink(inode))) {
  67                 iput(dir);
  68                 iput(inode);
  69                 *res_inode = NULL;
  70                 return -ELOOP;
  71         }
  72         iput(inode);
  73         __asm__("mov %0,%%fs"::"r" ((unsigned short) 0x10));
  74         current->link_count++;
  75         error = open_namei(pnt,flag,mode,res_inode,dir);
  76         current->link_count--;
  77         __asm__("mov %0,%%fs"::"r" (fs));
  78         kfree(pnt);
  79         return error;
  80 }
  81 
  82 static int isofs_readlink(struct inode * inode, char * buffer, int buflen)
     /* [previous][next][first][last][top][bottom][index][help] */
  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_fs_byte(c,buffer++);
 105         }
 106         kfree(pnt);
 107         return i;
 108 }

/* [previous][next][first][last][top][bottom][index][help] */