]> Git Repo - linux.git/blame - fs/affs/symlink.c
Merge tag 'tty-6.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
[linux.git] / fs / affs / symlink.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
1da177e4
LT
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
1b6f3c87 14static int affs_symlink_read_folio(struct file *file, struct folio *folio)
1da177e4
LT
15{
16 struct buffer_head *bh;
41a638a1
MWO
17 struct inode *inode = folio->mapping->host;
18 char *link = folio_address(folio);
1da177e4 19 struct slink_front *lf;
1da177e4
LT
20 int i, j;
21 char c;
22 char lc;
1da177e4 23
6b255391 24 pr_debug("get_link(ino=%lu)\n", inode->i_ino);
1da177e4 25
1da177e4
LT
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;
1da177e4
LT
33
34 if (strchr(lf->symname,':')) { /* Handle assign or volume name */
29333920
AV
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 : "/";
1da177e4
LT
39 while (i < 1023 && (c = pf[i]))
40 link[i++] = c;
29333920 41 spin_unlock(&sbi->symlink_lock);
1da177e4
LT
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);
41a638a1
MWO
60 folio_mark_uptodate(folio);
61 folio_unlock(folio);
1da177e4
LT
62 return 0;
63fail:
41a638a1 64 folio_unlock(folio);
196a4f82 65 return -EIO;
1da177e4
LT
66}
67
f5e54d6e 68const struct address_space_operations affs_symlink_aops = {
1b6f3c87 69 .read_folio = affs_symlink_read_folio,
1da177e4
LT
70};
71
754661f1 72const struct inode_operations affs_symlink_inode_operations = {
6b255391 73 .get_link = page_get_link,
1da177e4
LT
74 .setattr = affs_notify_change,
75};
This page took 1.128666 seconds and 4 git commands to generate.