Blame view
fs/squashfs/symlink.c
3.66 KB
1dc4bba39 Squashfs: symlink... |
1 2 3 4 |
/* * Squashfs - a compressed read only filesystem for Linux * * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
d7f2ff671 Squashfs: update ... |
5 |
* Phillip Lougher <phillip@squashfs.org.uk> |
1dc4bba39 Squashfs: symlink... |
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * symlink.c */ /* * This file implements code to handle symbolic links. * * The data contents of symbolic links are stored inside the symbolic * link inode within the inode table. This allows the normally small symbolic * link to be compressed as part of the inode table, achieving much greater * compression than if the symbolic link was compressed individually. */ #include <linux/fs.h> #include <linux/vfs.h> #include <linux/kernel.h> |
1dc4bba39 Squashfs: symlink... |
36 37 |
#include <linux/string.h> #include <linux/pagemap.h> |
67f66cc6c squashfs: add new... |
38 |
#include <linux/xattr.h> |
1dc4bba39 Squashfs: symlink... |
39 40 41 42 43 |
#include "squashfs_fs.h" #include "squashfs_fs_sb.h" #include "squashfs_fs_i.h" #include "squashfs.h" |
01e5b4e4e squashfs: add xat... |
44 |
#include "xattr.h" |
1dc4bba39 Squashfs: symlink... |
45 46 47 48 49 50 |
static int squashfs_symlink_readpage(struct file *file, struct page *page) { struct inode *inode = page->mapping->host; struct super_block *sb = inode->i_sb; struct squashfs_sb_info *msblk = sb->s_fs_info; |
09cbfeaf1 mm, fs: get rid o... |
51 |
int index = page->index << PAGE_SHIFT; |
1dc4bba39 Squashfs: symlink... |
52 53 |
u64 block = squashfs_i(inode)->start; int offset = squashfs_i(inode)->offset; |
09cbfeaf1 mm, fs: get rid o... |
54 |
int length = min_t(int, i_size_read(inode) - index, PAGE_SIZE); |
1dc4bba39 Squashfs: symlink... |
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
int bytes, copied; void *pageaddr; struct squashfs_cache_entry *entry; TRACE("Entered squashfs_symlink_readpage, page index %ld, start block " "%llx, offset %x ", page->index, block, offset); /* * Skip index bytes into symlink metadata. */ if (index) { bytes = squashfs_read_metadata(sb, NULL, &block, &offset, index); if (bytes < 0) { ERROR("Unable to read symlink [%llx:%x] ", squashfs_i(inode)->start, squashfs_i(inode)->offset); goto error_out; } } /* * Read length bytes from symlink metadata. Squashfs_read_metadata * is not used here because it can sleep and we want to use * kmap_atomic to map the page. Instead call the underlying * squashfs_cache_get routine. As length bytes may overlap metadata * blocks, we may need to call squashfs_cache_get multiple times. */ for (bytes = 0; bytes < length; offset = 0, bytes += copied) { entry = squashfs_cache_get(sb, msblk->block_cache, block, 0); if (entry->error) { ERROR("Unable to read symlink [%llx:%x] ", squashfs_i(inode)->start, squashfs_i(inode)->offset); squashfs_cache_put(entry); goto error_out; } |
53b55e558 squashfs: remove ... |
95 |
pageaddr = kmap_atomic(page); |
1dc4bba39 Squashfs: symlink... |
96 97 98 |
copied = squashfs_copy_data(pageaddr + bytes, entry, offset, length - bytes); if (copied == length - bytes) |
09cbfeaf1 mm, fs: get rid o... |
99 |
memset(pageaddr + length, 0, PAGE_SIZE - length); |
1dc4bba39 Squashfs: symlink... |
100 101 |
else block = entry->next_index; |
53b55e558 squashfs: remove ... |
102 |
kunmap_atomic(pageaddr); |
1dc4bba39 Squashfs: symlink... |
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
squashfs_cache_put(entry); } flush_dcache_page(page); SetPageUptodate(page); unlock_page(page); return 0; error_out: SetPageError(page); unlock_page(page); return 0; } const struct address_space_operations squashfs_symlink_aops = { .readpage = squashfs_symlink_readpage }; |
67f66cc6c squashfs: add new... |
121 122 |
const struct inode_operations squashfs_symlink_inode_ops = { |
6b2553918 replace ->follow_... |
123 |
.get_link = page_get_link, |
67f66cc6c squashfs: add new... |
124 125 |
.listxattr = squashfs_listxattr }; |