Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 310064
b: refs/heads/master
c: 90ad1a8
h: refs/heads/master
v: v3
  • Loading branch information
Miklos Szeredi authored and Al Viro committed Jun 1, 2012
1 parent 25f7410 commit 3ddb2e3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5f5daac12a4cef568d1269be0215fec0667193c1
refs/heads/master: 90ad1a8ecb9bfd5ff4503ac42cd049a97643ee51
1 change: 1 addition & 0 deletions trunk/fs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ extern struct file *do_file_open_root(struct dentry *, struct vfsmount *,

extern long do_handle_open(int mountdirfd,
struct file_handle __user *ufh, int open_flag);
extern int open_check_o_direct(struct file *f);

/*
* inode.c
Expand Down
47 changes: 33 additions & 14 deletions trunk/fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,23 @@ static inline int __get_file_write_access(struct inode *inode,
return error;
}

static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
struct file *f,
int (*open)(struct inode *, struct file *),
const struct cred *cred)
int open_check_o_direct(struct file *f)
{
/* NB: we're sure to have correct a_ops only after f_op->open */
if (f->f_flags & O_DIRECT) {
if (!f->f_mapping->a_ops ||
((!f->f_mapping->a_ops->direct_IO) &&
(!f->f_mapping->a_ops->get_xip_mem))) {
return -EINVAL;
}
}
return 0;
}

static struct file *do_dentry_open(struct dentry *dentry, struct vfsmount *mnt,
struct file *f,
int (*open)(struct inode *, struct file *),
const struct cred *cred)
{
static const struct file_operations empty_fops = {};
struct inode *inode;
Expand Down Expand Up @@ -713,16 +726,6 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,

file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);

/* NB: we're sure to have correct a_ops only after f_op->open */
if (f->f_flags & O_DIRECT) {
if (!f->f_mapping->a_ops ||
((!f->f_mapping->a_ops->direct_IO) &&
(!f->f_mapping->a_ops->get_xip_mem))) {
fput(f);
f = ERR_PTR(-EINVAL);
}
}

return f;

cleanup_all:
Expand Down Expand Up @@ -750,6 +753,22 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
return ERR_PTR(error);
}

static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
struct file *f,
int (*open)(struct inode *, struct file *),
const struct cred *cred)
{
struct file *res = do_dentry_open(dentry, mnt, f, open, cred);
if (!IS_ERR(res)) {
int error = open_check_o_direct(f);
if (error) {
fput(res);
res = ERR_PTR(error);
}
}
return res;
}

/**
* lookup_instantiate_filp - instantiates the open intent filp
* @nd: pointer to nameidata
Expand Down

0 comments on commit 3ddb2e3

Please sign in to comment.