Release 4.11 fs/udf/symlink.c
/*
* symlink.c
*
* PURPOSE
* Symlink handling routines for the OSTA-UDF(tm) filesystem.
*
* COPYRIGHT
* This file is distributed under the terms of the GNU General Public
* License (GPL). Copies of the GPL can be obtained from:
* ftp://prep.ai.mit.edu/pub/gnu/GPL
* Each contributing author retains all rights to their own work.
*
* (C) 1998-2001 Ben Fennema
* (C) 1999 Stelias Computing Inc
*
* HISTORY
*
* 04/16/99 blf Created.
*
*/
#include "udfdecl.h"
#include <linux/uaccess.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/time.h>
#include <linux/mm.h>
#include <linux/stat.h>
#include <linux/pagemap.h>
#include "udf_i.h"
static int udf_pc_to_char(struct super_block *sb, unsigned char *from,
int fromlen, unsigned char *to, int tolen)
{
struct pathComponent *pc;
int elen = 0;
int comp_len;
unsigned char *p = to;
/* Reserve one byte for terminating \0 */
tolen--;
while (elen < fromlen) {
pc = (struct pathComponent *)(from + elen);
elen += sizeof(struct pathComponent);
switch (pc->componentType) {
case 1:
/*
* Symlink points to some place which should be agreed
* upon between originator and receiver of the media. Ignore.
*/
if (pc->lengthComponentIdent > 0) {
elen += pc->lengthComponentIdent;
break;
}
/* Fall through */
case 2:
if (tolen == 0)
return -ENAMETOOLONG;
p = to;
*p++ = '/';
tolen--;
break;
case 3:
if (tolen < 3)
return -ENAMETOOLONG;
memcpy(p, "../", 3);
p += 3;
tolen -= 3;
break;
case 4:
if (tolen < 2)
return -ENAMETOOLONG;
memcpy(p, "./", 2);
p += 2;
tolen -= 2;
/* that would be . - just ignore */
break;
case 5:
elen += pc->lengthComponentIdent;
if (elen > fromlen)
return -EIO;
comp_len = udf_get_filename(sb, pc->componentIdent,
pc->lengthComponentIdent,
p, tolen);
if (comp_len < 0)
return comp_len;
p += comp_len;
tolen -= comp_len;
if (tolen == 0)
return -ENAMETOOLONG;
*p++ = '/';
tolen--;
break;
}
}
if (p > to + 1)
p[-1] = '\0';
else
p[0] = '\0';
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 157 | 51.99% | 3 | 30.00% |
Jan Kara | 121 | 40.07% | 3 | 30.00% |
Ben Fennema | 12 | 3.97% | 2 | 20.00% |
Fabian Frederick | 9 | 2.98% | 1 | 10.00% |
Al Viro | 3 | 0.99% | 1 | 10.00% |
Total | 302 | 100.00% | 10 | 100.00% |
static int udf_symlink_filler(struct file *file, struct page *page)
{
struct inode *inode = page->mapping->host;
struct buffer_head *bh = NULL;
unsigned char *symlink;
int err;
unsigned char *p = page_address(page);
struct udf_inode_info *iinfo;
uint32_t pos;
/* We don't support symlinks longer than one block */
if (inode->i_size > inode->i_sb->s_blocksize) {
err = -ENAMETOOLONG;
goto out_unmap;
}
iinfo = UDF_I(inode);
pos = udf_block_map(inode, 0);
down_read(&iinfo->i_data_sem);
if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
symlink = iinfo->i_ext.i_data + iinfo->i_lenEAttr;
} else {
bh = sb_bread(inode->i_sb, pos);
if (!bh) {
err = -EIO;
goto out_unlock_inode;
}
symlink = bh->b_data;
}
err = udf_pc_to_char(inode->i_sb, symlink, inode->i_size, p, PAGE_SIZE);
brelse(bh);
if (err)
goto out_unlock_inode;
up_read(&iinfo->i_data_sem);
SetPageUptodate(page);
unlock_page(page);
return 0;
out_unlock_inode:
up_read(&iinfo->i_data_sem);
SetPageError(page);
out_unmap:
unlock_page(page);
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 123 | 51.04% | 5 | 27.78% |
Jan Kara | 46 | 19.09% | 3 | 16.67% |
Alessio Igor Bogani | 35 | 14.52% | 1 | 5.56% |
Marcin Ślusarz | 22 | 9.13% | 2 | 11.11% |
Ben Fennema | 6 | 2.49% | 2 | 11.11% |
Al Viro | 3 | 1.24% | 2 | 11.11% |
Linus Torvalds | 2 | 0.83% | 1 | 5.56% |
Andrew Morton | 2 | 0.83% | 1 | 5.56% |
Cyrill V. Gorcunov | 2 | 0.83% | 1 | 5.56% |
Total | 241 | 100.00% | 18 | 100.00% |
static int udf_symlink_getattr(const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags)
{
struct dentry *dentry = path->dentry;
struct inode *inode = d_backing_inode(dentry);
struct page *page;
generic_fillattr(inode, stat);
page = read_mapping_page(inode->i_mapping, 0, NULL);
if (IS_ERR(page))
return PTR_ERR(page);
/*
* UDF uses non-trivial encoding of symlinks so i_size does not match
* number of characters reported by readlink(2) which apparently some
* applications expect. Also POSIX says that "The value returned in the
* st_size field shall be the length of the contents of the symbolic
* link, and shall not count a trailing null if one is present." So
* let's report the length of string returned by readlink(2) for
* st_size.
*/
stat->size = strlen(page_address(page));
put_page(page);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jan Kara | 83 | 81.37% | 1 | 50.00% |
David Howells | 19 | 18.63% | 1 | 50.00% |
Total | 102 | 100.00% | 2 | 100.00% |
/*
* symlinks can't do much...
*/
const struct address_space_operations udf_symlink_aops = {
.readpage = udf_symlink_filler,
};
const struct inode_operations udf_symlink_inode_operations = {
.get_link = page_get_link,
.getattr = udf_symlink_getattr,
};
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 315 | 44.81% | 6 | 21.43% |
Jan Kara | 267 | 37.98% | 6 | 21.43% |
Alessio Igor Bogani | 35 | 4.98% | 1 | 3.57% |
Marcin Ślusarz | 22 | 3.13% | 2 | 7.14% |
David Howells | 19 | 2.70% | 1 | 3.57% |
Ben Fennema | 18 | 2.56% | 2 | 7.14% |
Fabian Frederick | 10 | 1.42% | 2 | 7.14% |
Al Viro | 6 | 0.85% | 2 | 7.14% |
Cyrill V. Gorcunov | 3 | 0.43% | 1 | 3.57% |
Art Haas | 2 | 0.28% | 1 | 3.57% |
Andrew Morton | 2 | 0.28% | 1 | 3.57% |
Linus Torvalds | 2 | 0.28% | 1 | 3.57% |
Dave Jones | 1 | 0.14% | 1 | 3.57% |
Christoph Hellwig | 1 | 0.14% | 1 | 3.57% |
Total | 703 | 100.00% | 28 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.