You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: "The big thing in this pile is Eric's unmount-on-rmdir series; we finally have everything we need for that. The final piece of prereqs is delayed mntput() - now filesystem shutdown always happens on shallow stack. Other than that, we have several new primitives for iov_iter (Matt Wilcox, culled from his XIP-related series) pushing the conversion to ->read_iter()/ ->write_iter() a bit more, a bunch of fs/dcache.c cleanups and fixes (including the external name refcounting, which gives consistent behaviour of d_move() wrt procfs symlinks for long and short names alike) and assorted cleanups and fixes all over the place. This is just the first pile; there's a lot of stuff from various people that ought to go in this window. Starting with unionmount/overlayfs mess... ;-/" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (60 commits) fs/file_table.c: Update alloc_file() comment vfs: Deduplicate code shared by xattr system calls operating on paths reiserfs: remove pointless forward declaration of struct nameidata don't need that forward declaration of struct nameidata in dcache.h anymore take dname_external() into fs/dcache.c let path_init() failures treated the same way as subsequent link_path_walk() fix misuses of f_count() in ppp and netlink ncpfs: use list_for_each_entry() for d_subdirs walk vfs: move getname() from callers to do_mount() gfs2_atomic_open(): skip lookups on hashed dentry [infiniband] remove pointless assignments gadgetfs: saner API for gadgetfs_create_file() f_fs: saner API for ffs_sb_create_file() jfs: don't hash direct inode [s390] remove pointless assignment of ->f_op in vmlogrdr ->open() ecryptfs: ->f_op is never NULL android: ->f_op is never NULL nouveau: __iomem misannotations missing annotation in fs/file.c fs: namespace: suppress 'may be used uninitialized' warnings ...
This commit is contained in:
@@ -237,7 +237,7 @@ noted. This means that most methods can block safely. All methods are
|
||||
only called from a process context (i.e. not from an interrupt handler
|
||||
or bottom half).
|
||||
|
||||
alloc_inode: this method is called by inode_alloc() to allocate memory
|
||||
alloc_inode: this method is called by alloc_inode() to allocate memory
|
||||
for struct inode and initialize it. If this function is not
|
||||
defined, a simple 'struct inode' is allocated. Normally
|
||||
alloc_inode will be used to allocate a larger structure which
|
||||
|
||||
+10
-13
@@ -446,7 +446,8 @@ struct procfs_args {
|
||||
* unhappy with OSF UFS. [CHECKME]
|
||||
*/
|
||||
static int
|
||||
osf_ufs_mount(const char *dirname, struct ufs_args __user *args, int flags)
|
||||
osf_ufs_mount(const char __user *dirname,
|
||||
struct ufs_args __user *args, int flags)
|
||||
{
|
||||
int retval;
|
||||
struct cdfs_args tmp;
|
||||
@@ -466,7 +467,8 @@ osf_ufs_mount(const char *dirname, struct ufs_args __user *args, int flags)
|
||||
}
|
||||
|
||||
static int
|
||||
osf_cdfs_mount(const char *dirname, struct cdfs_args __user *args, int flags)
|
||||
osf_cdfs_mount(const char __user *dirname,
|
||||
struct cdfs_args __user *args, int flags)
|
||||
{
|
||||
int retval;
|
||||
struct cdfs_args tmp;
|
||||
@@ -486,7 +488,8 @@ osf_cdfs_mount(const char *dirname, struct cdfs_args __user *args, int flags)
|
||||
}
|
||||
|
||||
static int
|
||||
osf_procfs_mount(const char *dirname, struct procfs_args __user *args, int flags)
|
||||
osf_procfs_mount(const char __user *dirname,
|
||||
struct procfs_args __user *args, int flags)
|
||||
{
|
||||
struct procfs_args tmp;
|
||||
|
||||
@@ -500,28 +503,22 @@ SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
|
||||
int, flag, void __user *, data)
|
||||
{
|
||||
int retval;
|
||||
struct filename *name;
|
||||
|
||||
name = getname(path);
|
||||
retval = PTR_ERR(name);
|
||||
if (IS_ERR(name))
|
||||
goto out;
|
||||
switch (typenr) {
|
||||
case 1:
|
||||
retval = osf_ufs_mount(name->name, data, flag);
|
||||
retval = osf_ufs_mount(path, data, flag);
|
||||
break;
|
||||
case 6:
|
||||
retval = osf_cdfs_mount(name->name, data, flag);
|
||||
retval = osf_cdfs_mount(path, data, flag);
|
||||
break;
|
||||
case 9:
|
||||
retval = osf_procfs_mount(name->name, data, flag);
|
||||
retval = osf_procfs_mount(path, data, flag);
|
||||
break;
|
||||
default:
|
||||
retval = -EINVAL;
|
||||
printk("osf_mount(%ld, %x)\n", typenr, flag);
|
||||
}
|
||||
putname(name);
|
||||
out:
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
@@ -308,11 +308,8 @@ static int load_aout_binary(struct linux_binprm *bprm)
|
||||
(current->mm->start_brk = N_BSSADDR(ex));
|
||||
|
||||
retval = setup_arg_pages(bprm, IA32_STACK_TOP, EXSTACK_DEFAULT);
|
||||
if (retval < 0) {
|
||||
/* Someone check-me: is this error path enough? */
|
||||
send_sig(SIGKILL, current, 0);
|
||||
if (retval < 0)
|
||||
return retval;
|
||||
}
|
||||
|
||||
install_exec_creds(bprm);
|
||||
|
||||
@@ -324,17 +321,13 @@ static int load_aout_binary(struct linux_binprm *bprm)
|
||||
|
||||
error = vm_brk(text_addr & PAGE_MASK, map_size);
|
||||
|
||||
if (error != (text_addr & PAGE_MASK)) {
|
||||
send_sig(SIGKILL, current, 0);
|
||||
if (error != (text_addr & PAGE_MASK))
|
||||
return error;
|
||||
}
|
||||
|
||||
error = read_code(bprm->file, text_addr, 32,
|
||||
ex.a_text + ex.a_data);
|
||||
if ((signed long)error < 0) {
|
||||
send_sig(SIGKILL, current, 0);
|
||||
if ((signed long)error < 0)
|
||||
return error;
|
||||
}
|
||||
} else {
|
||||
#ifdef WARN_OLD
|
||||
static unsigned long error_time, error_time2;
|
||||
@@ -368,20 +361,16 @@ static int load_aout_binary(struct linux_binprm *bprm)
|
||||
MAP_EXECUTABLE | MAP_32BIT,
|
||||
fd_offset);
|
||||
|
||||
if (error != N_TXTADDR(ex)) {
|
||||
send_sig(SIGKILL, current, 0);
|
||||
if (error != N_TXTADDR(ex))
|
||||
return error;
|
||||
}
|
||||
|
||||
error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE |
|
||||
MAP_EXECUTABLE | MAP_32BIT,
|
||||
fd_offset + ex.a_text);
|
||||
if (error != N_DATADDR(ex)) {
|
||||
send_sig(SIGKILL, current, 0);
|
||||
if (error != N_DATADDR(ex))
|
||||
return error;
|
||||
}
|
||||
}
|
||||
beyond_if:
|
||||
set_binfmt(&aout_format);
|
||||
|
||||
+18
-67
@@ -62,12 +62,6 @@ static DEFINE_SPINLOCK(rsxx_ida_lock);
|
||||
|
||||
/* --------------------Debugfs Setup ------------------- */
|
||||
|
||||
struct rsxx_cram {
|
||||
u32 f_pos;
|
||||
u32 offset;
|
||||
void *i_private;
|
||||
};
|
||||
|
||||
static int rsxx_attr_pci_regs_show(struct seq_file *m, void *p)
|
||||
{
|
||||
struct rsxx_cardinfo *card = m->private;
|
||||
@@ -184,93 +178,50 @@ static int rsxx_attr_pci_regs_open(struct inode *inode, struct file *file)
|
||||
static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf,
|
||||
size_t cnt, loff_t *ppos)
|
||||
{
|
||||
struct rsxx_cram *info = fp->private_data;
|
||||
struct rsxx_cardinfo *card = info->i_private;
|
||||
struct rsxx_cardinfo *card = file_inode(fp)->i_private;
|
||||
char *buf;
|
||||
int st;
|
||||
ssize_t st;
|
||||
|
||||
buf = kzalloc(sizeof(*buf) * cnt, GFP_KERNEL);
|
||||
buf = kzalloc(cnt, GFP_KERNEL);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
info->f_pos = (u32)*ppos + info->offset;
|
||||
|
||||
st = rsxx_creg_read(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1);
|
||||
if (st)
|
||||
return st;
|
||||
|
||||
st = copy_to_user(ubuf, buf, cnt);
|
||||
if (st)
|
||||
return st;
|
||||
|
||||
info->offset += cnt;
|
||||
|
||||
st = rsxx_creg_read(card, CREG_ADD_CRAM + (u32)*ppos, cnt, buf, 1);
|
||||
if (!st)
|
||||
st = copy_to_user(ubuf, buf, cnt);
|
||||
kfree(buf);
|
||||
|
||||
if (st)
|
||||
return st;
|
||||
*ppos += cnt;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
static ssize_t rsxx_cram_write(struct file *fp, const char __user *ubuf,
|
||||
size_t cnt, loff_t *ppos)
|
||||
{
|
||||
struct rsxx_cram *info = fp->private_data;
|
||||
struct rsxx_cardinfo *card = info->i_private;
|
||||
struct rsxx_cardinfo *card = file_inode(fp)->i_private;
|
||||
char *buf;
|
||||
int st;
|
||||
ssize_t st;
|
||||
|
||||
buf = kzalloc(sizeof(*buf) * cnt, GFP_KERNEL);
|
||||
buf = kzalloc(cnt, GFP_KERNEL);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
st = copy_from_user(buf, ubuf, cnt);
|
||||
if (st)
|
||||
return st;
|
||||
|
||||
info->f_pos = (u32)*ppos + info->offset;
|
||||
|
||||
st = rsxx_creg_write(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1);
|
||||
if (st)
|
||||
return st;
|
||||
|
||||
info->offset += cnt;
|
||||
|
||||
if (!st)
|
||||
st = rsxx_creg_write(card, CREG_ADD_CRAM + (u32)*ppos, cnt,
|
||||
buf, 1);
|
||||
kfree(buf);
|
||||
|
||||
if (st)
|
||||
return st;
|
||||
*ppos += cnt;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
static int rsxx_cram_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct rsxx_cram *info = kzalloc(sizeof(*info), GFP_KERNEL);
|
||||
if (!info)
|
||||
return -ENOMEM;
|
||||
|
||||
info->i_private = inode->i_private;
|
||||
info->f_pos = file->f_pos;
|
||||
file->private_data = info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rsxx_cram_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct rsxx_cram *info = file->private_data;
|
||||
|
||||
if (!info)
|
||||
return 0;
|
||||
|
||||
kfree(info);
|
||||
file->private_data = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct file_operations debugfs_cram_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = rsxx_cram_open,
|
||||
.read = rsxx_cram_read,
|
||||
.write = rsxx_cram_write,
|
||||
.release = rsxx_cram_release,
|
||||
};
|
||||
|
||||
static const struct file_operations debugfs_stats_fops = {
|
||||
|
||||
@@ -160,13 +160,11 @@ static int vhci_create_device(struct vhci_data *data, __u8 opcode)
|
||||
}
|
||||
|
||||
static inline ssize_t vhci_get_user(struct vhci_data *data,
|
||||
const struct iovec *iov,
|
||||
unsigned long count)
|
||||
struct iov_iter *from)
|
||||
{
|
||||
size_t len = iov_length(iov, count);
|
||||
size_t len = iov_iter_count(from);
|
||||
struct sk_buff *skb;
|
||||
__u8 pkt_type, opcode;
|
||||
unsigned long i;
|
||||
int ret;
|
||||
|
||||
if (len < 2 || len > HCI_MAX_FRAME_SIZE)
|
||||
@@ -176,12 +174,9 @@ static inline ssize_t vhci_get_user(struct vhci_data *data,
|
||||
if (!skb)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (copy_from_user(skb_put(skb, iov[i].iov_len),
|
||||
iov[i].iov_base, iov[i].iov_len)) {
|
||||
kfree_skb(skb);
|
||||
return -EFAULT;
|
||||
}
|
||||
if (copy_from_iter(skb_put(skb, len), len, from) != len) {
|
||||
kfree_skb(skb);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
pkt_type = *((__u8 *) skb->data);
|
||||
@@ -294,13 +289,12 @@ static ssize_t vhci_read(struct file *file,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t vhci_write(struct kiocb *iocb, const struct iovec *iov,
|
||||
unsigned long count, loff_t pos)
|
||||
static ssize_t vhci_write(struct kiocb *iocb, struct iov_iter *from)
|
||||
{
|
||||
struct file *file = iocb->ki_filp;
|
||||
struct vhci_data *data = file->private_data;
|
||||
|
||||
return vhci_get_user(data, iov, count);
|
||||
return vhci_get_user(data, from);
|
||||
}
|
||||
|
||||
static unsigned int vhci_poll(struct file *file, poll_table *wait)
|
||||
@@ -365,7 +359,7 @@ static int vhci_release(struct inode *inode, struct file *file)
|
||||
static const struct file_operations vhci_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.read = vhci_read,
|
||||
.aio_write = vhci_write,
|
||||
.write_iter = vhci_write,
|
||||
.poll = vhci_poll,
|
||||
.open = vhci_open,
|
||||
.release = vhci_release,
|
||||
|
||||
+17
-47
@@ -622,53 +622,23 @@ static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out,
|
||||
return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null);
|
||||
}
|
||||
|
||||
static ssize_t read_zero(struct file *file, char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
size_t written;
|
||||
|
||||
if (!count)
|
||||
return 0;
|
||||
|
||||
if (!access_ok(VERIFY_WRITE, buf, count))
|
||||
return -EFAULT;
|
||||
|
||||
written = 0;
|
||||
while (count) {
|
||||
unsigned long unwritten;
|
||||
size_t chunk = count;
|
||||
|
||||
if (chunk > PAGE_SIZE)
|
||||
chunk = PAGE_SIZE; /* Just for latency reasons */
|
||||
unwritten = __clear_user(buf, chunk);
|
||||
written += chunk - unwritten;
|
||||
if (unwritten)
|
||||
break;
|
||||
if (signal_pending(current))
|
||||
return written ? written : -ERESTARTSYS;
|
||||
buf += chunk;
|
||||
count -= chunk;
|
||||
cond_resched();
|
||||
}
|
||||
return written ? written : -EFAULT;
|
||||
}
|
||||
|
||||
static ssize_t aio_read_zero(struct kiocb *iocb, const struct iovec *iov,
|
||||
unsigned long nr_segs, loff_t pos)
|
||||
static ssize_t read_iter_zero(struct kiocb *iocb, struct iov_iter *iter)
|
||||
{
|
||||
size_t written = 0;
|
||||
unsigned long i;
|
||||
ssize_t ret;
|
||||
|
||||
for (i = 0; i < nr_segs; i++) {
|
||||
ret = read_zero(iocb->ki_filp, iov[i].iov_base, iov[i].iov_len,
|
||||
&pos);
|
||||
if (ret < 0)
|
||||
break;
|
||||
written += ret;
|
||||
while (iov_iter_count(iter)) {
|
||||
size_t chunk = iov_iter_count(iter), n;
|
||||
if (chunk > PAGE_SIZE)
|
||||
chunk = PAGE_SIZE; /* Just for latency reasons */
|
||||
n = iov_iter_zero(chunk, iter);
|
||||
if (!n && iov_iter_count(iter))
|
||||
return written ? written : -EFAULT;
|
||||
written += n;
|
||||
if (signal_pending(current))
|
||||
return written ? written : -ERESTARTSYS;
|
||||
cond_resched();
|
||||
}
|
||||
|
||||
return written ? written : -EFAULT;
|
||||
return written;
|
||||
}
|
||||
|
||||
static int mmap_zero(struct file *file, struct vm_area_struct *vma)
|
||||
@@ -738,7 +708,6 @@ static int open_port(struct inode *inode, struct file *filp)
|
||||
#define zero_lseek null_lseek
|
||||
#define full_lseek null_lseek
|
||||
#define write_zero write_null
|
||||
#define read_full read_zero
|
||||
#define aio_write_zero aio_write_null
|
||||
#define open_mem open_port
|
||||
#define open_kmem open_mem
|
||||
@@ -783,9 +752,9 @@ static const struct file_operations port_fops = {
|
||||
|
||||
static const struct file_operations zero_fops = {
|
||||
.llseek = zero_lseek,
|
||||
.read = read_zero,
|
||||
.read = new_sync_read,
|
||||
.write = write_zero,
|
||||
.aio_read = aio_read_zero,
|
||||
.read_iter = read_iter_zero,
|
||||
.aio_write = aio_write_zero,
|
||||
.mmap = mmap_zero,
|
||||
};
|
||||
@@ -802,7 +771,8 @@ static struct backing_dev_info zero_bdi = {
|
||||
|
||||
static const struct file_operations full_fops = {
|
||||
.llseek = full_lseek,
|
||||
.read = read_full,
|
||||
.read = new_sync_read,
|
||||
.read_iter = read_iter_zero,
|
||||
.write = write_full,
|
||||
};
|
||||
|
||||
|
||||
@@ -799,7 +799,7 @@ static int dma_buf_describe(struct seq_file *s)
|
||||
seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%s\n",
|
||||
buf_obj->size,
|
||||
buf_obj->file->f_flags, buf_obj->file->f_mode,
|
||||
(long)(buf_obj->file->f_count.counter),
|
||||
file_count(buf_obj->file),
|
||||
buf_obj->exp_name);
|
||||
|
||||
seq_puts(s, "\tAttached Devices:\n");
|
||||
|
||||
@@ -40,12 +40,12 @@
|
||||
#include "nouveau_usif.h"
|
||||
|
||||
static void
|
||||
nvkm_client_unmap(void *priv, void *ptr, u32 size)
|
||||
nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size)
|
||||
{
|
||||
iounmap(ptr);
|
||||
}
|
||||
|
||||
static void *
|
||||
static void __iomem *
|
||||
nvkm_client_map(void *priv, u64 handle, u32 size)
|
||||
{
|
||||
return ioremap(handle, size);
|
||||
|
||||
@@ -9,8 +9,8 @@ struct nvif_driver {
|
||||
int (*suspend)(void *priv);
|
||||
int (*resume)(void *priv);
|
||||
int (*ioctl)(void *priv, bool super, void *data, u32 size, void **hack);
|
||||
void *(*map)(void *priv, u64 handle, u32 size);
|
||||
void (*unmap)(void *priv, void *ptr, u32 size);
|
||||
void __iomem *(*map)(void *priv, u64 handle, u32 size);
|
||||
void (*unmap)(void *priv, void __iomem *ptr, u32 size);
|
||||
bool keep;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ struct nvif_object {
|
||||
void *priv; /*XXX: hack */
|
||||
void (*dtor)(struct nvif_object *);
|
||||
struct {
|
||||
void *ptr;
|
||||
void __iomem *ptr;
|
||||
u32 size;
|
||||
} map;
|
||||
};
|
||||
@@ -42,7 +42,7 @@ void nvif_object_unmap(struct nvif_object *);
|
||||
struct nvif_object *_object = nvif_object(a); \
|
||||
u32 _data; \
|
||||
if (likely(_object->map.ptr)) \
|
||||
_data = ioread##b##_native((u8 *)_object->map.ptr + (c)); \
|
||||
_data = ioread##b##_native((u8 __iomem *)_object->map.ptr + (c)); \
|
||||
else \
|
||||
_data = nvif_object_rd(_object, (b) / 8, (c)); \
|
||||
_data; \
|
||||
@@ -50,7 +50,7 @@ void nvif_object_unmap(struct nvif_object *);
|
||||
#define nvif_wr(a,b,c,d) ({ \
|
||||
struct nvif_object *_object = nvif_object(a); \
|
||||
if (likely(_object->map.ptr)) \
|
||||
iowrite##b##_native((d), (u8 *)_object->map.ptr + (c)); \
|
||||
iowrite##b##_native((d), (u8 __iomem *)_object->map.ptr + (c)); \
|
||||
else \
|
||||
nvif_object_wr(_object, (b) / 8, (c), (d)); \
|
||||
})
|
||||
|
||||
@@ -82,7 +82,6 @@ static int create_file(const char *name, umode_t mode,
|
||||
{
|
||||
int error;
|
||||
|
||||
*dentry = NULL;
|
||||
mutex_lock(&parent->d_inode->i_mutex);
|
||||
*dentry = lookup_one_len(name, parent, strlen(name));
|
||||
if (!IS_ERR(*dentry))
|
||||
|
||||
@@ -89,7 +89,6 @@ static int create_file(const char *name, umode_t mode,
|
||||
{
|
||||
int error;
|
||||
|
||||
*dentry = NULL;
|
||||
mutex_lock(&parent->d_inode->i_mutex);
|
||||
*dentry = lookup_one_len(name, parent, strlen(name));
|
||||
if (!IS_ERR(*dentry))
|
||||
|
||||
@@ -749,13 +749,8 @@ static ssize_t fpga_read(struct file *filp, char __user *buf, size_t count,
|
||||
loff_t *f_pos)
|
||||
{
|
||||
struct fpga_dev *priv = filp->private_data;
|
||||
|
||||
count = min_t(size_t, priv->bytes - *f_pos, count);
|
||||
if (copy_to_user(buf, priv->vb.vaddr + *f_pos, count))
|
||||
return -EFAULT;
|
||||
|
||||
*f_pos += count;
|
||||
return count;
|
||||
return simple_read_from_buffer(buf, count, ppos,
|
||||
priv->vb.vaddr, priv->bytes);
|
||||
}
|
||||
|
||||
static loff_t fpga_llseek(struct file *filp, loff_t offset, int origin)
|
||||
@@ -767,26 +762,7 @@ static loff_t fpga_llseek(struct file *filp, loff_t offset, int origin)
|
||||
if ((filp->f_flags & O_ACCMODE) != O_RDONLY)
|
||||
return -EINVAL;
|
||||
|
||||
switch (origin) {
|
||||
case SEEK_SET: /* seek relative to the beginning of the file */
|
||||
newpos = offset;
|
||||
break;
|
||||
case SEEK_CUR: /* seek relative to current position in the file */
|
||||
newpos = filp->f_pos + offset;
|
||||
break;
|
||||
case SEEK_END: /* seek relative to the end of the file */
|
||||
newpos = priv->fw_size - offset;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* check for sanity */
|
||||
if (newpos > priv->fw_size)
|
||||
return -EINVAL;
|
||||
|
||||
filp->f_pos = newpos;
|
||||
return newpos;
|
||||
return fixed_size_llseek(file, offset, origin, priv->fw_size);
|
||||
}
|
||||
|
||||
static const struct file_operations fpga_fops = {
|
||||
|
||||
@@ -594,7 +594,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
if (file == ppp->owner)
|
||||
ppp_shutdown_interface(ppp);
|
||||
}
|
||||
if (atomic_long_read(&file->f_count) <= 2) {
|
||||
if (atomic_long_read(&file->f_count) < 2) {
|
||||
ppp_release(NULL, file);
|
||||
err = 0;
|
||||
} else
|
||||
|
||||
@@ -338,7 +338,6 @@ static int vmlogrdr_open (struct inode *inode, struct file *filp)
|
||||
|
||||
/* set the file options */
|
||||
filp->private_data = logptr;
|
||||
filp->f_op = &vmlogrdr_fops;
|
||||
|
||||
/* start recording for this service*/
|
||||
if (logptr->autorecording) {
|
||||
|
||||
@@ -339,7 +339,7 @@ static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = asma->file->f_op->llseek(asma->file, offset, origin);
|
||||
ret = vfs_llseek(asma->file, offset, origin);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
long ret;
|
||||
|
||||
if (!filp->f_op || !filp->f_op->unlocked_ioctl)
|
||||
if (!filp->f_op->unlocked_ioctl)
|
||||
return -ENOTTY;
|
||||
|
||||
switch (cmd) {
|
||||
|
||||
@@ -411,69 +411,18 @@ static void fix_up_readers(struct logger_log *log, size_t len)
|
||||
}
|
||||
|
||||
/*
|
||||
* do_write_log - writes 'len' bytes from 'buf' to 'log'
|
||||
*
|
||||
* The caller needs to hold log->mutex.
|
||||
*/
|
||||
static void do_write_log(struct logger_log *log, const void *buf, size_t count)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = min(count, log->size - log->w_off);
|
||||
memcpy(log->buffer + log->w_off, buf, len);
|
||||
|
||||
if (count != len)
|
||||
memcpy(log->buffer, buf + len, count - len);
|
||||
|
||||
log->w_off = logger_offset(log, log->w_off + count);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* do_write_log_user - writes 'len' bytes from the user-space buffer 'buf' to
|
||||
* the log 'log'
|
||||
*
|
||||
* The caller needs to hold log->mutex.
|
||||
*
|
||||
* Returns 'count' on success, negative error code on failure.
|
||||
*/
|
||||
static ssize_t do_write_log_from_user(struct logger_log *log,
|
||||
const void __user *buf, size_t count)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = min(count, log->size - log->w_off);
|
||||
if (len && copy_from_user(log->buffer + log->w_off, buf, len))
|
||||
return -EFAULT;
|
||||
|
||||
if (count != len)
|
||||
if (copy_from_user(log->buffer, buf + len, count - len))
|
||||
/*
|
||||
* Note that by not updating w_off, this abandons the
|
||||
* portion of the new entry that *was* successfully
|
||||
* copied, just above. This is intentional to avoid
|
||||
* message corruption from missing fragments.
|
||||
*/
|
||||
return -EFAULT;
|
||||
|
||||
log->w_off = logger_offset(log, log->w_off + count);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
* logger_aio_write - our write method, implementing support for write(),
|
||||
* logger_write_iter - our write method, implementing support for write(),
|
||||
* writev(), and aio_write(). Writes are our fast path, and we try to optimize
|
||||
* them above all else.
|
||||
*/
|
||||
static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
||||
unsigned long nr_segs, loff_t ppos)
|
||||
static ssize_t logger_write_iter(struct kiocb *iocb, struct iov_iter *from)
|
||||
{
|
||||
struct logger_log *log = file_get_log(iocb->ki_filp);
|
||||
size_t orig;
|
||||
struct logger_entry header;
|
||||
struct timespec now;
|
||||
ssize_t ret = 0;
|
||||
size_t len, count;
|
||||
|
||||
count = min_t(size_t, iocb->ki_nbytes, LOGGER_ENTRY_MAX_PAYLOAD);
|
||||
|
||||
now = current_kernel_time();
|
||||
|
||||
@@ -482,7 +431,7 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
||||
header.sec = now.tv_sec;
|
||||
header.nsec = now.tv_nsec;
|
||||
header.euid = current_euid();
|
||||
header.len = min_t(size_t, iocb->ki_nbytes, LOGGER_ENTRY_MAX_PAYLOAD);
|
||||
header.len = count;
|
||||
header.hdr_size = sizeof(struct logger_entry);
|
||||
|
||||
/* null writes succeed, return zero */
|
||||
@@ -491,8 +440,6 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
||||
|
||||
mutex_lock(&log->mutex);
|
||||
|
||||
orig = log->w_off;
|
||||
|
||||
/*
|
||||
* Fix up any readers, pulling them forward to the first readable
|
||||
* entry after (what will be) the new write offset. We do this now
|
||||
@@ -501,33 +448,35 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
||||
*/
|
||||
fix_up_readers(log, sizeof(struct logger_entry) + header.len);
|
||||
|
||||
do_write_log(log, &header, sizeof(struct logger_entry));
|
||||
len = min(sizeof(header), log->size - log->w_off);
|
||||
memcpy(log->buffer + log->w_off, &header, len);
|
||||
memcpy(log->buffer, (char *)&header + len, sizeof(header) - len);
|
||||
|
||||
while (nr_segs-- > 0) {
|
||||
size_t len;
|
||||
ssize_t nr;
|
||||
len = min(count, log->size - log->w_off);
|
||||
|
||||
/* figure out how much of this vector we can keep */
|
||||
len = min_t(size_t, iov->iov_len, header.len - ret);
|
||||
|
||||
/* write out this segment's payload */
|
||||
nr = do_write_log_from_user(log, iov->iov_base, len);
|
||||
if (unlikely(nr < 0)) {
|
||||
log->w_off = orig;
|
||||
mutex_unlock(&log->mutex);
|
||||
return nr;
|
||||
}
|
||||
|
||||
iov++;
|
||||
ret += nr;
|
||||
if (copy_from_iter(log->buffer + log->w_off, len, from) != len) {
|
||||
/*
|
||||
* Note that by not updating w_off, this abandons the
|
||||
* portion of the new entry that *was* successfully
|
||||
* copied, just above. This is intentional to avoid
|
||||
* message corruption from missing fragments.
|
||||
*/
|
||||
mutex_unlock(&log->mutex);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (copy_from_iter(log->buffer, count - len, from) != count - len) {
|
||||
mutex_unlock(&log->mutex);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
log->w_off = logger_offset(log, log->w_off + count);
|
||||
mutex_unlock(&log->mutex);
|
||||
|
||||
/* wake up any blocked readers */
|
||||
wake_up_interruptible(&log->wq);
|
||||
|
||||
return ret;
|
||||
return len;
|
||||
}
|
||||
|
||||
static struct logger_log *get_log_from_minor(int minor)
|
||||
@@ -736,7 +685,7 @@ static long logger_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
static const struct file_operations logger_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.read = logger_read,
|
||||
.aio_write = logger_aio_write,
|
||||
.write_iter = logger_write_iter,
|
||||
.poll = logger_poll,
|
||||
.unlocked_ioctl = logger_ioctl,
|
||||
.compat_ioctl = logger_ioctl,
|
||||
|
||||
@@ -410,41 +410,19 @@ static ssize_t vme_user_write(struct file *file, const char __user *buf,
|
||||
|
||||
static loff_t vme_user_llseek(struct file *file, loff_t off, int whence)
|
||||
{
|
||||
loff_t absolute = -1;
|
||||
unsigned int minor = MINOR(file_inode(file)->i_rdev);
|
||||
size_t image_size;
|
||||
loff_t res;
|
||||
|
||||
if (minor == CONTROL_MINOR)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&image[minor].mutex);
|
||||
image_size = vme_get_size(image[minor].resource);
|
||||
|
||||
switch (whence) {
|
||||
case SEEK_SET:
|
||||
absolute = off;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
absolute = file->f_pos + off;
|
||||
break;
|
||||
case SEEK_END:
|
||||
absolute = image_size + off;
|
||||
break;
|
||||
default:
|
||||
mutex_unlock(&image[minor].mutex);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((absolute < 0) || (absolute >= image_size)) {
|
||||
mutex_unlock(&image[minor].mutex);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
file->f_pos = absolute;
|
||||
|
||||
res = fixed_size_llseek(file, off, whence, image_size);
|
||||
mutex_unlock(&image[minor].mutex);
|
||||
|
||||
return absolute;
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -164,10 +164,9 @@ struct ffs_desc_helper {
|
||||
static int __must_check ffs_epfiles_create(struct ffs_data *ffs);
|
||||
static void ffs_epfiles_destroy(struct ffs_epfile *epfiles, unsigned count);
|
||||
|
||||
static struct inode *__must_check
|
||||
static struct dentry *
|
||||
ffs_sb_create_file(struct super_block *sb, const char *name, void *data,
|
||||
const struct file_operations *fops,
|
||||
struct dentry **dentry_p);
|
||||
const struct file_operations *fops);
|
||||
|
||||
/* Devices management *******************************************************/
|
||||
|
||||
@@ -1119,10 +1118,9 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
|
||||
}
|
||||
|
||||
/* Create "regular" file */
|
||||
static struct inode *ffs_sb_create_file(struct super_block *sb,
|
||||
static struct dentry *ffs_sb_create_file(struct super_block *sb,
|
||||
const char *name, void *data,
|
||||
const struct file_operations *fops,
|
||||
struct dentry **dentry_p)
|
||||
const struct file_operations *fops)
|
||||
{
|
||||
struct ffs_data *ffs = sb->s_fs_info;
|
||||
struct dentry *dentry;
|
||||
@@ -1141,10 +1139,7 @@ static struct inode *ffs_sb_create_file(struct super_block *sb,
|
||||
}
|
||||
|
||||
d_add(dentry, inode);
|
||||
if (dentry_p)
|
||||
*dentry_p = dentry;
|
||||
|
||||
return inode;
|
||||
return dentry;
|
||||
}
|
||||
|
||||
/* Super block */
|
||||
@@ -1189,7 +1184,7 @@ static int ffs_sb_fill(struct super_block *sb, void *_data, int silent)
|
||||
|
||||
/* EP0 file */
|
||||
if (unlikely(!ffs_sb_create_file(sb, "ep0", ffs,
|
||||
&ffs_ep0_operations, NULL)))
|
||||
&ffs_ep0_operations)))
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
@@ -1561,9 +1556,10 @@ static int ffs_epfiles_create(struct ffs_data *ffs)
|
||||
sprintf(epfiles->name, "ep%02x", ffs->eps_addrmap[i]);
|
||||
else
|
||||
sprintf(epfiles->name, "ep%u", i);
|
||||
if (!unlikely(ffs_sb_create_file(ffs->sb, epfiles->name, epfile,
|
||||
&ffs_epfile_operations,
|
||||
&epfile->dentry))) {
|
||||
epfile->dentry = ffs_sb_create_file(ffs->sb, epfiles->name,
|
||||
epfile,
|
||||
&ffs_epfile_operations);
|
||||
if (unlikely(!epfile->dentry)) {
|
||||
ffs_epfiles_destroy(epfiles, i - 1);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user