|
@@ -821,15 +821,14 @@ static inline int __get_file_write_access(struct inode *inode,
|
|
}
|
|
}
|
|
|
|
|
|
static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
|
|
static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
|
|
- int flags, struct file *f,
|
|
|
|
|
|
+ struct file *f,
|
|
int (*open)(struct inode *, struct file *),
|
|
int (*open)(struct inode *, struct file *),
|
|
const struct cred *cred)
|
|
const struct cred *cred)
|
|
{
|
|
{
|
|
struct inode *inode;
|
|
struct inode *inode;
|
|
int error;
|
|
int error;
|
|
|
|
|
|
- f->f_flags = flags;
|
|
|
|
- f->f_mode = (__force fmode_t)((flags+1) & O_ACCMODE) | FMODE_LSEEK |
|
|
|
|
|
|
+ f->f_mode = (__force fmode_t)((f->f_flags+1) & O_ACCMODE) | FMODE_LSEEK |
|
|
FMODE_PREAD | FMODE_PWRITE;
|
|
FMODE_PREAD | FMODE_PWRITE;
|
|
inode = dentry->d_inode;
|
|
inode = dentry->d_inode;
|
|
if (f->f_mode & FMODE_WRITE) {
|
|
if (f->f_mode & FMODE_WRITE) {
|
|
@@ -930,7 +929,6 @@ struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry
|
|
if (IS_ERR(dentry))
|
|
if (IS_ERR(dentry))
|
|
goto out_err;
|
|
goto out_err;
|
|
nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->path.mnt),
|
|
nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->path.mnt),
|
|
- nd->intent.open.flags - 1,
|
|
|
|
nd->intent.open.file,
|
|
nd->intent.open.file,
|
|
open, cred);
|
|
open, cred);
|
|
out:
|
|
out:
|
|
@@ -949,7 +947,7 @@ EXPORT_SYMBOL_GPL(lookup_instantiate_filp);
|
|
*
|
|
*
|
|
* Note that this function destroys the original nameidata
|
|
* Note that this function destroys the original nameidata
|
|
*/
|
|
*/
|
|
-struct file *nameidata_to_filp(struct nameidata *nd, int flags)
|
|
|
|
|
|
+struct file *nameidata_to_filp(struct nameidata *nd)
|
|
{
|
|
{
|
|
const struct cred *cred = current_cred();
|
|
const struct cred *cred = current_cred();
|
|
struct file *filp;
|
|
struct file *filp;
|
|
@@ -958,7 +956,7 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags)
|
|
filp = nd->intent.open.file;
|
|
filp = nd->intent.open.file;
|
|
/* Has the filesystem initialised the file for us? */
|
|
/* Has the filesystem initialised the file for us? */
|
|
if (filp->f_path.dentry == NULL)
|
|
if (filp->f_path.dentry == NULL)
|
|
- filp = __dentry_open(nd->path.dentry, nd->path.mnt, flags, filp,
|
|
|
|
|
|
+ filp = __dentry_open(nd->path.dentry, nd->path.mnt, filp,
|
|
NULL, cred);
|
|
NULL, cred);
|
|
else
|
|
else
|
|
path_put(&nd->path);
|
|
path_put(&nd->path);
|
|
@@ -997,7 +995,8 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags,
|
|
return ERR_PTR(error);
|
|
return ERR_PTR(error);
|
|
}
|
|
}
|
|
|
|
|
|
- return __dentry_open(dentry, mnt, flags, f, NULL, cred);
|
|
|
|
|
|
+ f->f_flags = flags;
|
|
|
|
+ return __dentry_open(dentry, mnt, f, NULL, cred);
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(dentry_open);
|
|
EXPORT_SYMBOL(dentry_open);
|
|
|
|
|