Commit 839a3c61 authored by Pavel Emelyanov's avatar Pavel Emelyanov

files: Don't call fstatfs twice

When filling fd_parms we do call statfs, no need to call it
again later.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2ceb6786
...@@ -294,11 +294,14 @@ static int dump_chrdev(struct fd_parms *p, int lfd, const int fdinfo) ...@@ -294,11 +294,14 @@ static int dump_chrdev(struct fd_parms *p, int lfd, const int fdinfo)
#define PIPEFS_MAGIC 0x50495045 #define PIPEFS_MAGIC 0x50495045
#endif #endif
#ifndef ANON_INODE_FS_MAGIC
# define ANON_INODE_FS_MAGIC 0x09041934
#endif
static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_opts *opts, static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_opts *opts,
const int fdinfo) const int fdinfo)
{ {
struct fd_parms p = FD_PARMS_INIT; struct fd_parms p = FD_PARMS_INIT;
struct statfs statfs;
const struct fdtype_ops *ops; const struct fdtype_ops *ops;
if (fill_fd_params(ctl, fd, lfd, opts, &p) < 0) { if (fill_fd_params(ctl, fd, lfd, opts, &p) < 0) {
...@@ -312,12 +315,7 @@ static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_op ...@@ -312,12 +315,7 @@ static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_op
if (S_ISCHR(p.stat.st_mode)) if (S_ISCHR(p.stat.st_mode))
return dump_chrdev(&p, lfd, fdinfo); return dump_chrdev(&p, lfd, fdinfo);
if (fstatfs(lfd, &statfs)) { if (p.fs_type == ANON_INODE_FS_MAGIC) {
pr_perror("Can't obtain statfs on fd %d", fd);
return -1;
}
if (is_anon_inode(&statfs)) {
if (is_eventfd_link(lfd)) if (is_eventfd_link(lfd))
ops = &eventfd_dump_ops; ops = &eventfd_dump_ops;
else if (is_eventpoll_link(lfd)) else if (is_eventpoll_link(lfd))
...@@ -357,7 +355,7 @@ static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_op ...@@ -357,7 +355,7 @@ static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_op
} }
if (S_ISFIFO(p.stat.st_mode)) { if (S_ISFIFO(p.stat.st_mode)) {
if (statfs.f_type == PIPEFS_MAGIC) if (p.fs_type == PIPEFS_MAGIC)
ops = &pipe_dump_ops; ops = &pipe_dump_ops;
else else
ops = &fifo_dump_ops; ops = &fifo_dump_ops;
......
...@@ -234,7 +234,6 @@ static inline dev_t kdev_to_odev(u32 kdev) ...@@ -234,7 +234,6 @@ static inline dev_t kdev_to_odev(u32 kdev)
} }
extern int copy_file(int fd_in, int fd_out, size_t bytes); extern int copy_file(int fd_in, int fd_out, size_t bytes);
extern bool is_anon_inode(struct statfs *statfs);
extern int is_anon_link_type(int lfd, char *type); extern int is_anon_link_type(int lfd, char *type);
#define is_hex_digit(c) \ #define is_hex_digit(c) \
......
...@@ -404,15 +404,6 @@ int copy_file(int fd_in, int fd_out, size_t bytes) ...@@ -404,15 +404,6 @@ int copy_file(int fd_in, int fd_out, size_t bytes)
return 0; return 0;
} }
#ifndef ANON_INODE_FS_MAGIC
# define ANON_INODE_FS_MAGIC 0x09041934
#endif
bool is_anon_inode(struct statfs *statfs)
{
return statfs->f_type == ANON_INODE_FS_MAGIC;
}
int read_fd_link(int lfd, char *buf, size_t size) int read_fd_link(int lfd, char *buf, size_t size)
{ {
char t[32]; char t[32];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment