Revision 33844e665104b169a3a7732bdcddb40e4f82b335 authored by Al Viro on 22 December 2016, 02:55:02 UTC, committed by Al Viro on 23 December 2016, 04:00:22 UTC
Problem similar to ones dealt with in "fold checks into iterate_and_advance()" and followups, except that in this case we really want to do nothing when asked for zero-length operation - unlike zero-length iterate_and_advance(), zero-length iterate_all_kinds() has no side effects, and callers are simpler that way. That got exposed when copy_from_iter_full() had been used by tipc, which builds an msghdr with zero payload and (now) feeds it to a primitive based on iterate_all_kinds() instead of iterate_and_advance(). Reported-by: Jon Maloy <jon.maloy@ericsson.com> Tested-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent c00d2c7
symlink.c
/*
* linux/fs/affs/symlink.c
*
* 1995 Hans-Joachim Widmaier - Modified for affs.
*
* Copyright (C) 1991, 1992 Linus Torvalds
*
* affs symlink handling code
*/
#include "affs.h"
static int affs_symlink_readpage(struct file *file, struct page *page)
{
struct buffer_head *bh;
struct inode *inode = page->mapping->host;
char *link = page_address(page);
struct slink_front *lf;
int i, j;
char c;
char lc;
pr_debug("get_link(ino=%lu)\n", inode->i_ino);
bh = affs_bread(inode->i_sb, inode->i_ino);
if (!bh)
goto fail;
i = 0;
j = 0;
lf = (struct slink_front *)bh->b_data;
lc = 0;
if (strchr(lf->symname,':')) { /* Handle assign or volume name */
struct affs_sb_info *sbi = AFFS_SB(inode->i_sb);
char *pf;
spin_lock(&sbi->symlink_lock);
pf = sbi->s_prefix ? sbi->s_prefix : "/";
while (i < 1023 && (c = pf[i]))
link[i++] = c;
spin_unlock(&sbi->symlink_lock);
while (i < 1023 && lf->symname[j] != ':')
link[i++] = lf->symname[j++];
if (i < 1023)
link[i++] = '/';
j++;
lc = '/';
}
while (i < 1023 && (c = lf->symname[j])) {
if (c == '/' && lc == '/' && i < 1020) { /* parent dir */
link[i++] = '.';
link[i++] = '.';
}
link[i++] = c;
lc = c;
j++;
}
link[i] = '\0';
affs_brelse(bh);
SetPageUptodate(page);
unlock_page(page);
return 0;
fail:
SetPageError(page);
unlock_page(page);
return -EIO;
}
const struct address_space_operations affs_symlink_aops = {
.readpage = affs_symlink_readpage,
};
const struct inode_operations affs_symlink_inode_operations = {
.get_link = page_get_link,
.setattr = affs_notify_change,
};
Computing file changes ...