Commit 4b0d41c5 authored by Pavel Emelyanov's avatar Pavel Emelyanov

image: Don't unlink image we're dumping into

We want to write into empty image files, so we
unlink them before dumping into. Let's O_TRUNC
it instead.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
parent 6efe3f5d
...@@ -192,14 +192,6 @@ int open_image_at(int dfd, int type, unsigned long flags, ...) ...@@ -192,14 +192,6 @@ int open_image_at(int dfd, int type, unsigned long flags, ...)
vsnprintf(path, PATH_MAX, fdset_template[type].fmt, args); vsnprintf(path, PATH_MAX, fdset_template[type].fmt, args);
va_end(args); va_end(args);
if (flags & O_EXCL) {
ret = unlinkat(dfd, path, 0);
if (ret && errno != ENOENT) {
pr_perror("Unable to unlink %s", path);
goto err;
}
}
ret = openat(dfd, path, flags, CR_FD_PERM); ret = openat(dfd, path, flags, CR_FD_PERM);
if (ret < 0) { if (ret < 0) {
pr_perror("Unable to open %s", path); pr_perror("Unable to open %s", path);
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
extern bool fdinfo_per_id; extern bool fdinfo_per_id;
extern bool ns_per_id; extern bool ns_per_id;
#define O_DUMP (O_RDWR | O_CREAT | O_EXCL) #define O_DUMP (O_RDWR | O_CREAT | O_TRUNC)
#define O_SHOW (O_RDONLY) #define O_SHOW (O_RDONLY)
#define O_RSTR (O_RDONLY) #define O_RSTR (O_RDONLY)
......
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