~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/affs/symlink.c

Version: ~ [ linux-5.7 ] ~ [ linux-5.6.15 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.43 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.125 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.182 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.225 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.225 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.84 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  *  linux/fs/affs/symlink.c
  4  *
  5  *  1995  Hans-Joachim Widmaier - Modified for affs.
  6  *
  7  *  Copyright (C) 1991, 1992  Linus Torvalds
  8  *
  9  *  affs symlink handling code
 10  */
 11 
 12 #include "affs.h"
 13 
 14 static int affs_symlink_readpage(struct file *file, struct page *page)
 15 {
 16         struct buffer_head *bh;
 17         struct inode *inode = page->mapping->host;
 18         char *link = page_address(page);
 19         struct slink_front *lf;
 20         int                      i, j;
 21         char                     c;
 22         char                     lc;
 23 
 24         pr_debug("get_link(ino=%lu)\n", inode->i_ino);
 25 
 26         bh = affs_bread(inode->i_sb, inode->i_ino);
 27         if (!bh)
 28                 goto fail;
 29         i  = 0;
 30         j  = 0;
 31         lf = (struct slink_front *)bh->b_data;
 32         lc = 0;
 33 
 34         if (strchr(lf->symname,':')) {  /* Handle assign or volume name */
 35                 struct affs_sb_info *sbi = AFFS_SB(inode->i_sb);
 36                 char *pf;
 37                 spin_lock(&sbi->symlink_lock);
 38                 pf = sbi->s_prefix ? sbi->s_prefix : "/";
 39                 while (i < 1023 && (c = pf[i]))
 40                         link[i++] = c;
 41                 spin_unlock(&sbi->symlink_lock);
 42                 while (i < 1023 && lf->symname[j] != ':')
 43                         link[i++] = lf->symname[j++];
 44                 if (i < 1023)
 45                         link[i++] = '/';
 46                 j++;
 47                 lc = '/';
 48         }
 49         while (i < 1023 && (c = lf->symname[j])) {
 50                 if (c == '/' && lc == '/' && i < 1020) {        /* parent dir */
 51                         link[i++] = '.';
 52                         link[i++] = '.';
 53                 }
 54                 link[i++] = c;
 55                 lc = c;
 56                 j++;
 57         }
 58         link[i] = '\0';
 59         affs_brelse(bh);
 60         SetPageUptodate(page);
 61         unlock_page(page);
 62         return 0;
 63 fail:
 64         SetPageError(page);
 65         unlock_page(page);
 66         return -EIO;
 67 }
 68 
 69 const struct address_space_operations affs_symlink_aops = {
 70         .readpage       = affs_symlink_readpage,
 71 };
 72 
 73 const struct inode_operations affs_symlink_inode_operations = {
 74         .get_link       = page_get_link,
 75         .setattr        = affs_notify_change,
 76 };
 77 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp