projects
/
platform
/
upstream
/
cryptsetup.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
32cfb1c
)
Fix directio (again).
author
Milan Broz
<gmazyland@gmail.com>
Sat, 16 Jun 2012 18:59:21 +0000
(20:59 +0200)
committer
Milan Broz
<gmazyland@gmail.com>
Sat, 16 Jun 2012 18:59:21 +0000
(20:59 +0200)
src/crypt_reencrypt.c
patch
|
blob
|
history
diff --git
a/src/crypt_reencrypt.c
b/src/crypt_reencrypt.c
index
7708dd6
..
07cbbf3
100644
(file)
--- a/
src/crypt_reencrypt.c
+++ b/
src/crypt_reencrypt.c
@@
-79,6
+79,7
@@
struct reenc_ctx {
char crypt_path_org[PATH_MAX];
char crypt_path_new[PATH_MAX];
int log_fd;
char crypt_path_org[PATH_MAX];
char crypt_path_new[PATH_MAX];
int log_fd;
+ char *log_buf;
struct {
char *password;
struct {
char *password;
@@
-344,18
+345,17
@@
static int parse_line_log(struct reenc_ctx *rc, const char *line)
static int parse_log(struct reenc_ctx *rc)
{
static int parse_log(struct reenc_ctx *rc)
{
- static char buf[SECTOR_SIZE];
char *start, *end;
ssize_t s;
char *start, *end;
ssize_t s;
- s = read(rc->log_fd, buf, SECTOR_SIZE);
+ s = read(rc->log_fd,
rc->log_
buf, SECTOR_SIZE);
if (s == -1) {
log_err(_("Cannot read reencryption log file.\n"));
return -EIO;
}
if (s == -1) {
log_err(_("Cannot read reencryption log file.\n"));
return -EIO;
}
- buf[SECTOR_SIZE - 1] = '\0';
- start = buf;
+
rc->log_
buf[SECTOR_SIZE - 1] = '\0';
+ start =
rc->log_
buf;
do {
end = strchr(start, '\n');
if (end) {
do {
end = strchr(start, '\n');
if (end) {
@@
-372,6
+372,15
@@
static int parse_log(struct reenc_ctx *rc)
return 0;
}
return 0;
}
+static void close_log(struct reenc_ctx *rc)
+{
+ log_dbg("Closing LUKS reencryption log file %s.", rc->log_file);
+ if (rc->log_fd != -1)
+ close(rc->log_fd);
+ free(rc->log_buf);
+ rc->log_buf = NULL;
+}
+
static int open_log(struct reenc_ctx *rc)
{
int flags;
static int open_log(struct reenc_ctx *rc)
{
int flags;
@@
-394,17
+403,16
@@
static int open_log(struct reenc_ctx *rc)
rc->in_progress = 1;
}
rc->in_progress = 1;
}
+ if (posix_memalign((void *)&rc->log_buf, alignment(rc->log_fd), SECTOR_SIZE)) {
+ log_err(_("Allocation of aligned memory failed.\n"));
+ close_log(rc);
+ return -ENOMEM;
+ }
+
/* Be sure it is correct format */
return parse_log(rc);
}
/* Be sure it is correct format */
return parse_log(rc);
}
-static void close_log(struct reenc_ctx *rc)
-{
- log_dbg("Closing LUKS reencryption log file %s.", rc->log_file);
- if (rc->log_fd != -1)
- close(rc->log_fd);
-}
-
static int activate_luks_headers(struct reenc_ctx *rc)
{
struct crypt_device *cd = NULL, *cd_new = NULL;
static int activate_luks_headers(struct reenc_ctx *rc)
{
struct crypt_device *cd = NULL, *cd_new = NULL;
@@
-565,7
+573,7
@@
static void print_progress(struct reenc_ctx *rc, uint64_t bytes, int final)
/* vt100 code clear line */
log_err("\33[2K\r");
/* vt100 code clear line */
log_err("\33[2K\r");
- log_err(_("Progress: %5.1f%%, time elapsed %
3.1
f seconds, "
+ log_err(_("Progress: %5.1f%%, time elapsed %
4.0
f seconds, "
"%4llu MiB written, speed %5.1f MiB/s%s"),
(double)bytes / rc->device_size * 100,
time_diff(rc->start_time, rc->end_time),
"%4llu MiB written, speed %5.1f MiB/s%s"),
(double)bytes / rc->device_size * 100,
time_diff(rc->start_time, rc->end_time),