Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
60545d0d
Commit
60545d0d
authored
Jun 07, 2013
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[O_TMPFILE] it's still short a few helpers, but infrastructure should be OK now...
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
f9652e10
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
164 additions
and
5 deletions
+164
-5
arch/alpha/include/uapi/asm/fcntl.h
arch/alpha/include/uapi/asm/fcntl.h
+1
-0
arch/parisc/include/uapi/asm/fcntl.h
arch/parisc/include/uapi/asm/fcntl.h
+1
-0
arch/sparc/include/uapi/asm/fcntl.h
arch/sparc/include/uapi/asm/fcntl.h
+1
-0
fs/dcache.c
fs/dcache.c
+16
-0
fs/ext2/namei.c
fs/ext2/namei.c
+24
-0
fs/minix/namei.c
fs/minix/namei.c
+13
-0
fs/namei.c
fs/namei.c
+60
-0
fs/open.c
fs/open.c
+9
-5
include/linux/dcache.h
include/linux/dcache.h
+2
-0
include/linux/fs.h
include/linux/fs.h
+1
-0
include/uapi/asm-generic/fcntl.h
include/uapi/asm-generic/fcntl.h
+4
-0
mm/shmem.c
mm/shmem.c
+32
-0
No files found.
arch/alpha/include/uapi/asm/fcntl.h
View file @
60545d0d
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#define O_SYNC (__O_SYNC|O_DSYNC)
#define O_SYNC (__O_SYNC|O_DSYNC)
#define O_PATH 040000000
#define O_PATH 040000000
#define O_TMPFILE 0100000000
#define F_GETLK 7
#define F_GETLK 7
#define F_SETLK 8
#define F_SETLK 8
...
...
arch/parisc/include/uapi/asm/fcntl.h
View file @
60545d0d
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#define O_INVISIBLE 004000000
/* invisible I/O, for DMAPI/XDSM */
#define O_INVISIBLE 004000000
/* invisible I/O, for DMAPI/XDSM */
#define O_PATH 020000000
#define O_PATH 020000000
#define O_TMPFILE 040000000
#define F_GETLK64 8
#define F_GETLK64 8
#define F_SETLK64 9
#define F_SETLK64 9
...
...
arch/sparc/include/uapi/asm/fcntl.h
View file @
60545d0d
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#define O_SYNC (__O_SYNC|O_DSYNC)
#define O_SYNC (__O_SYNC|O_DSYNC)
#define O_PATH 0x1000000
#define O_PATH 0x1000000
#define O_TMPFILE 0x2000000
#define F_GETOWN 5
/* for sockets. */
#define F_GETOWN 5
/* for sockets. */
#define F_SETOWN 6
/* for sockets. */
#define F_SETOWN 6
/* for sockets. */
...
...
fs/dcache.c
View file @
60545d0d
...
@@ -2968,6 +2968,22 @@ void d_genocide(struct dentry *root)
...
@@ -2968,6 +2968,22 @@ void d_genocide(struct dentry *root)
goto
again
;
goto
again
;
}
}
void
d_tmpfile
(
struct
dentry
*
dentry
,
struct
inode
*
inode
)
{
inode_dec_link_count
(
inode
);
BUG_ON
(
dentry
->
d_name
.
name
!=
dentry
->
d_iname
||
!
hlist_unhashed
(
&
dentry
->
d_alias
)
||
!
d_unlinked
(
dentry
));
spin_lock
(
&
dentry
->
d_parent
->
d_lock
);
spin_lock_nested
(
&
dentry
->
d_lock
,
DENTRY_D_LOCK_NESTED
);
dentry
->
d_name
.
len
=
sprintf
(
dentry
->
d_iname
,
"#%llu"
,
(
unsigned
long
long
)
inode
->
i_ino
);
spin_unlock
(
&
dentry
->
d_lock
);
spin_unlock
(
&
dentry
->
d_parent
->
d_lock
);
d_instantiate
(
dentry
,
inode
);
}
EXPORT_SYMBOL
(
d_tmpfile
);
/**
/**
* find_inode_number - check for dentry with name
* find_inode_number - check for dentry with name
* @dir: directory to check
* @dir: directory to check
...
...
fs/ext2/namei.c
View file @
60545d0d
...
@@ -119,6 +119,29 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode
...
@@ -119,6 +119,29 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode
return
ext2_add_nondir
(
dentry
,
inode
);
return
ext2_add_nondir
(
dentry
,
inode
);
}
}
static
int
ext2_tmpfile
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
umode_t
mode
)
{
struct
inode
*
inode
=
ext2_new_inode
(
dir
,
mode
,
NULL
);
if
(
IS_ERR
(
inode
))
return
PTR_ERR
(
inode
);
inode
->
i_op
=
&
ext2_file_inode_operations
;
if
(
ext2_use_xip
(
inode
->
i_sb
))
{
inode
->
i_mapping
->
a_ops
=
&
ext2_aops_xip
;
inode
->
i_fop
=
&
ext2_xip_file_operations
;
}
else
if
(
test_opt
(
inode
->
i_sb
,
NOBH
))
{
inode
->
i_mapping
->
a_ops
=
&
ext2_nobh_aops
;
inode
->
i_fop
=
&
ext2_file_operations
;
}
else
{
inode
->
i_mapping
->
a_ops
=
&
ext2_aops
;
inode
->
i_fop
=
&
ext2_file_operations
;
}
mark_inode_dirty
(
inode
);
d_tmpfile
(
dentry
,
inode
);
unlock_new_inode
(
inode
);
return
0
;
}
static
int
ext2_mknod
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
umode_t
mode
,
dev_t
rdev
)
static
int
ext2_mknod
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
umode_t
mode
,
dev_t
rdev
)
{
{
struct
inode
*
inode
;
struct
inode
*
inode
;
...
@@ -398,6 +421,7 @@ const struct inode_operations ext2_dir_inode_operations = {
...
@@ -398,6 +421,7 @@ const struct inode_operations ext2_dir_inode_operations = {
#endif
#endif
.
setattr
=
ext2_setattr
,
.
setattr
=
ext2_setattr
,
.
get_acl
=
ext2_get_acl
,
.
get_acl
=
ext2_get_acl
,
.
tmpfile
=
ext2_tmpfile
,
};
};
const
struct
inode_operations
ext2_special_inode_operations
=
{
const
struct
inode_operations
ext2_special_inode_operations
=
{
...
...
fs/minix/namei.c
View file @
60545d0d
...
@@ -54,6 +54,18 @@ static int minix_mknod(struct inode * dir, struct dentry *dentry, umode_t mode,
...
@@ -54,6 +54,18 @@ static int minix_mknod(struct inode * dir, struct dentry *dentry, umode_t mode,
return
error
;
return
error
;
}
}
static
int
minix_tmpfile
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
umode_t
mode
)
{
int
error
;
struct
inode
*
inode
=
minix_new_inode
(
dir
,
mode
,
&
error
);
if
(
inode
)
{
minix_set_inode
(
inode
,
0
);
mark_inode_dirty
(
inode
);
d_tmpfile
(
dentry
,
inode
);
}
return
error
;
}
static
int
minix_create
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
umode_t
mode
,
static
int
minix_create
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
umode_t
mode
,
bool
excl
)
bool
excl
)
{
{
...
@@ -254,4 +266,5 @@ const struct inode_operations minix_dir_inode_operations = {
...
@@ -254,4 +266,5 @@ const struct inode_operations minix_dir_inode_operations = {
.
mknod
=
minix_mknod
,
.
mknod
=
minix_mknod
,
.
rename
=
minix_rename
,
.
rename
=
minix_rename
,
.
getattr
=
minix_getattr
,
.
getattr
=
minix_getattr
,
.
tmpfile
=
minix_tmpfile
,
};
};
fs/namei.c
View file @
60545d0d
...
@@ -2902,6 +2902,61 @@ static int do_last(struct nameidata *nd, struct path *path,
...
@@ -2902,6 +2902,61 @@ static int do_last(struct nameidata *nd, struct path *path,
goto
retry_lookup
;
goto
retry_lookup
;
}
}
static
int
do_tmpfile
(
int
dfd
,
struct
filename
*
pathname
,
struct
nameidata
*
nd
,
int
flags
,
const
struct
open_flags
*
op
,
struct
file
*
file
,
int
*
opened
)
{
static
const
struct
qstr
name
=
QSTR_INIT
(
"/"
,
1
);
struct
dentry
*
dentry
,
*
child
;
struct
inode
*
dir
;
int
error
=
path_lookupat
(
dfd
,
pathname
->
name
,
flags
|
LOOKUP_DIRECTORY
,
nd
);
if
(
unlikely
(
error
))
return
error
;
error
=
mnt_want_write
(
nd
->
path
.
mnt
);
if
(
unlikely
(
error
))
goto
out
;
/* we want directory to be writable */
error
=
inode_permission
(
nd
->
inode
,
MAY_WRITE
|
MAY_EXEC
);
if
(
error
)
goto
out2
;
dentry
=
nd
->
path
.
dentry
;
dir
=
dentry
->
d_inode
;
if
(
!
dir
->
i_op
->
tmpfile
)
{
error
=
-
EOPNOTSUPP
;
goto
out2
;
}
child
=
d_alloc
(
dentry
,
&
name
);
if
(
unlikely
(
!
child
))
{
error
=
-
ENOMEM
;
goto
out2
;
}
nd
->
flags
&=
~
LOOKUP_DIRECTORY
;
nd
->
flags
|=
op
->
intent
;
dput
(
nd
->
path
.
dentry
);
nd
->
path
.
dentry
=
child
;
error
=
dir
->
i_op
->
tmpfile
(
dir
,
nd
->
path
.
dentry
,
op
->
mode
);
if
(
error
)
goto
out2
;
audit_inode
(
pathname
,
nd
->
path
.
dentry
,
0
);
error
=
may_open
(
&
nd
->
path
,
op
->
acc_mode
,
op
->
open_flag
);
if
(
error
)
goto
out2
;
file
->
f_path
.
mnt
=
nd
->
path
.
mnt
;
error
=
finish_open
(
file
,
nd
->
path
.
dentry
,
NULL
,
opened
);
if
(
error
)
goto
out2
;
error
=
open_check_o_direct
(
file
);
if
(
error
)
fput
(
file
);
out2:
mnt_drop_write
(
nd
->
path
.
mnt
);
out:
path_put
(
&
nd
->
path
);
return
error
;
}
static
struct
file
*
path_openat
(
int
dfd
,
struct
filename
*
pathname
,
static
struct
file
*
path_openat
(
int
dfd
,
struct
filename
*
pathname
,
struct
nameidata
*
nd
,
const
struct
open_flags
*
op
,
int
flags
)
struct
nameidata
*
nd
,
const
struct
open_flags
*
op
,
int
flags
)
{
{
...
@@ -2917,6 +2972,11 @@ static struct file *path_openat(int dfd, struct filename *pathname,
...
@@ -2917,6 +2972,11 @@ static struct file *path_openat(int dfd, struct filename *pathname,
file
->
f_flags
=
op
->
open_flag
;
file
->
f_flags
=
op
->
open_flag
;
if
(
unlikely
(
file
->
f_flags
&
O_TMPFILE
))
{
error
=
do_tmpfile
(
dfd
,
pathname
,
nd
,
flags
,
op
,
file
,
&
opened
);
goto
out
;
}
error
=
path_init
(
dfd
,
pathname
->
name
,
flags
|
LOOKUP_PARENT
,
nd
,
&
base
);
error
=
path_init
(
dfd
,
pathname
->
name
,
flags
|
LOOKUP_PARENT
,
nd
,
&
base
);
if
(
unlikely
(
error
))
if
(
unlikely
(
error
))
goto
out
;
goto
out
;
...
...
fs/open.c
View file @
60545d0d
...
@@ -840,11 +840,15 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
...
@@ -840,11 +840,15 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
if
(
flags
&
__O_SYNC
)
if
(
flags
&
__O_SYNC
)
flags
|=
O_DSYNC
;
flags
|=
O_DSYNC
;
/*
if
(
flags
&
O_TMPFILE
)
{
* If we have O_PATH in the open flag. Then we
if
(
!
(
flags
&
O_CREAT
))
* cannot have anything other than the below set of flags
return
-
EINVAL
;
*/
acc_mode
=
MAY_OPEN
|
ACC_MODE
(
flags
);
if
(
flags
&
O_PATH
)
{
}
else
if
(
flags
&
O_PATH
)
{
/*
* If we have O_PATH in the open flag. Then we
* cannot have anything other than the below set of flags
*/
flags
&=
O_DIRECTORY
|
O_NOFOLLOW
|
O_PATH
;
flags
&=
O_DIRECTORY
|
O_NOFOLLOW
|
O_PATH
;
acc_mode
=
0
;
acc_mode
=
0
;
}
else
{
}
else
{
...
...
include/linux/dcache.h
View file @
60545d0d
...
@@ -246,6 +246,8 @@ extern struct dentry * d_make_root(struct inode *);
...
@@ -246,6 +246,8 @@ extern struct dentry * d_make_root(struct inode *);
/* <clickety>-<click> the ramfs-type tree */
/* <clickety>-<click> the ramfs-type tree */
extern
void
d_genocide
(
struct
dentry
*
);
extern
void
d_genocide
(
struct
dentry
*
);
extern
void
d_tmpfile
(
struct
dentry
*
,
struct
inode
*
);
extern
struct
dentry
*
d_find_alias
(
struct
inode
*
);
extern
struct
dentry
*
d_find_alias
(
struct
inode
*
);
extern
void
d_prune_aliases
(
struct
inode
*
);
extern
void
d_prune_aliases
(
struct
inode
*
);
...
...
include/linux/fs.h
View file @
60545d0d
...
@@ -1580,6 +1580,7 @@ struct inode_operations {
...
@@ -1580,6 +1580,7 @@ struct inode_operations {
int
(
*
atomic_open
)(
struct
inode
*
,
struct
dentry
*
,
int
(
*
atomic_open
)(
struct
inode
*
,
struct
dentry
*
,
struct
file
*
,
unsigned
open_flag
,
struct
file
*
,
unsigned
open_flag
,
umode_t
create_mode
,
int
*
opened
);
umode_t
create_mode
,
int
*
opened
);
int
(
*
tmpfile
)
(
struct
inode
*
,
struct
dentry
*
,
umode_t
);
}
____cacheline_aligned
;
}
____cacheline_aligned
;
ssize_t
rw_copy_check_uvector
(
int
type
,
const
struct
iovec
__user
*
uvector
,
ssize_t
rw_copy_check_uvector
(
int
type
,
const
struct
iovec
__user
*
uvector
,
...
...
include/uapi/asm-generic/fcntl.h
View file @
60545d0d
...
@@ -84,6 +84,10 @@
...
@@ -84,6 +84,10 @@
#define O_PATH 010000000
#define O_PATH 010000000
#endif
#endif
#ifndef O_TMPFILE
#define O_TMPFILE 020000000
#endif
#ifndef O_NDELAY
#ifndef O_NDELAY
#define O_NDELAY O_NONBLOCK
#define O_NDELAY O_NONBLOCK
#endif
#endif
...
...
mm/shmem.c
View file @
60545d0d
...
@@ -1965,6 +1965,37 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
...
@@ -1965,6 +1965,37 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
return
error
;
return
error
;
}
}
static
int
shmem_tmpfile
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
umode_t
mode
)
{
struct
inode
*
inode
;
int
error
=
-
ENOSPC
;
inode
=
shmem_get_inode
(
dir
->
i_sb
,
dir
,
mode
,
0
,
VM_NORESERVE
);
if
(
inode
)
{
error
=
security_inode_init_security
(
inode
,
dir
,
NULL
,
shmem_initxattrs
,
NULL
);
if
(
error
)
{
if
(
error
!=
-
EOPNOTSUPP
)
{
iput
(
inode
);
return
error
;
}
}
#ifdef CONFIG_TMPFS_POSIX_ACL
error
=
generic_acl_init
(
inode
,
dir
);
if
(
error
)
{
iput
(
inode
);
return
error
;
}
#else
error
=
0
;
#endif
d_tmpfile
(
dentry
,
inode
);
}
return
error
;
}
static
int
shmem_mkdir
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
umode_t
mode
)
static
int
shmem_mkdir
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
umode_t
mode
)
{
{
int
error
;
int
error
;
...
@@ -2723,6 +2754,7 @@ static const struct inode_operations shmem_dir_inode_operations = {
...
@@ -2723,6 +2754,7 @@ static const struct inode_operations shmem_dir_inode_operations = {
.
rmdir
=
shmem_rmdir
,
.
rmdir
=
shmem_rmdir
,
.
mknod
=
shmem_mknod
,
.
mknod
=
shmem_mknod
,
.
rename
=
shmem_rename
,
.
rename
=
shmem_rename
,
.
tmpfile
=
shmem_tmpfile
,
#endif
#endif
#ifdef CONFIG_TMPFS_XATTR
#ifdef CONFIG_TMPFS_XATTR
.
setxattr
=
shmem_setxattr
,
.
setxattr
=
shmem_setxattr
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment