Commit e1d7ff8f authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

images: regfile -- Save file @mode into image

We will need it for NFS. While we're saving it
into image, the test for mode change must be
done in account with NFS. So put fixme there.

CC: Pavel Emelyanov <xemul@virtuozzo.com>
CC: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent f0f1a0a7
...@@ -1166,6 +1166,8 @@ ext: ...@@ -1166,6 +1166,8 @@ ext:
rfe.flags = p->flags; rfe.flags = p->flags;
rfe.pos = p->pos; rfe.pos = p->pos;
rfe.fown = (FownEntry *)&p->fown; rfe.fown = (FownEntry *)&p->fown;
rfe.has_mode = true;
rfe.mode = p->stat.st_mode;
if (S_ISREG(p->stat.st_mode) && should_check_size(rfe.flags)) { if (S_ISREG(p->stat.st_mode) && should_check_size(rfe.flags)) {
rfe.has_size = true; rfe.has_size = true;
...@@ -1471,7 +1473,8 @@ ext: ...@@ -1471,7 +1473,8 @@ ext:
return -1; return -1;
} }
if (rfi->rfe->has_size && !rfi->size_checked) { if ((rfi->rfe->has_size || rfi->rfe->has_mode) &&
!rfi->size_mode_checked) {
struct stat st; struct stat st;
if (fstat(tmp, &st) < 0) { if (fstat(tmp, &st) < 0) {
...@@ -1479,19 +1482,28 @@ ext: ...@@ -1479,19 +1482,28 @@ ext:
return -1; return -1;
} }
if (st.st_size != rfi->rfe->size) { if (rfi->rfe->has_size && (st.st_size != rfi->rfe->size)) {
pr_err("File %s has bad size %"PRIu64" (expect %"PRIu64")\n", pr_err("File %s has bad size %"PRIu64" (expect %"PRIu64")\n",
rfi->path, st.st_size, rfi->path, st.st_size,
rfi->rfe->size); rfi->rfe->size);
return -1; return -1;
} }
if (rfi->rfe->has_mode && (st.st_mode != rfi->rfe->mode)) {
if (st.st_mode != rfi->rfe->mode) {
pr_err("File %s has bad mode 0%o (expect 0%o)\n",
rfi->path, (int)st.st_mode,
rfi->rfe->mode);
return -1;
}
}
/* /*
* This is only visible in the current process, so * This is only visible in the current process, so
* change w/o locks. Other tasks sharing the same * change w/o locks. Other tasks sharing the same
* file will get one via unix sockets. * file will get one via unix sockets.
*/ */
rfi->size_checked = true; rfi->size_mode_checked = true;
} }
if (rfi->remap) { if (rfi->remap) {
...@@ -1696,7 +1708,7 @@ static int collect_one_regfile(void *o, ProtobufCMessage *base, struct cr_img *i ...@@ -1696,7 +1708,7 @@ static int collect_one_regfile(void *o, ProtobufCMessage *base, struct cr_img *i
else else
rfi->path = rfi->rfe->name + 1; rfi->path = rfi->rfe->name + 1;
rfi->remap = NULL; rfi->remap = NULL;
rfi->size_checked = false; rfi->size_mode_checked = false;
pr_info("Collected [%s] ID %#x\n", rfi->path, rfi->rfe->id); pr_info("Collected [%s] ID %#x\n", rfi->path, rfi->rfe->id);
return file_desc_add(&rfi->d, rfi->rfe->id, &reg_desc_ops); return file_desc_add(&rfi->d, rfi->rfe->id, &reg_desc_ops);
......
...@@ -22,7 +22,7 @@ struct reg_file_info { ...@@ -22,7 +22,7 @@ struct reg_file_info {
struct file_desc d; struct file_desc d;
RegFileEntry *rfe; RegFileEntry *rfe;
struct file_remap *remap; struct file_remap *remap;
bool size_checked; bool size_mode_checked;
bool is_dir; bool is_dir;
char *path; char *path;
}; };
......
...@@ -10,4 +10,5 @@ message reg_file_entry { ...@@ -10,4 +10,5 @@ message reg_file_entry {
optional sint32 mnt_id = 7 [default = -1]; optional sint32 mnt_id = 7 [default = -1];
optional uint64 size = 8; optional uint64 size = 8;
optional bool ext = 9; optional bool ext = 9;
optional uint32 mode = 10;
} }
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