Files
fos/Buildroot/package/partclone/partclone-0.3.47.patch
2026-04-06 12:05:30 -07:00

80 lines
2.8 KiB
Diff

diff --git a/Makefile.am b/Makefile.am
index 11a2657..bc33f40 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
AUTOMAKE_OPTIONS = subdir-objects
-SUBDIRS= po src docs tests
+SUBDIRS= po src
ACLOCAL_AMFLAGS = -I m4
diff --git a/src/progress.c b/src/progress.c
index 4a25c06..5937d25 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -220,6 +220,47 @@ static void calculate_speed(struct progress_bar *prog, unsigned long long copied
strncpy(prog_stat->Rformated, Rformated, sizeof(Rformated)+1);
}
+/// convert the size
+char* filesize_conv(double size, char *buf, size_t len) {
+ int i = 0;
+ const char* units[] = {"iB","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"};
+ while (size > 1024) {
+ size /= 1024;
+ i++;
+ }
+ snprintf(buf, len, "%.*f %s", i, size, units[i]);
+ return buf;
+}
+
+/// write data to log file for status/progress info
+void fogLogStatusFile(struct progress_bar *prog,struct prog_stat_t *prog_stat,unsigned long long current) {
+ FILE *fog_log;
+ fog_log = fopen("/tmp/status.fog","w");
+ if (fog_log == NULL) {
+ fprintf(stderr,"Error opening file %s","/tmp/status.fog");
+ exit(0);
+ }
+ double totalsize=prog->block_size * prog->total;
+ double currentsize=prog->block_size * current;
+ int max_len=15;
+ char total_str[max_len];
+ char current_str[max_len];
+ char buf[max_len];
+ sprintf(total_str,filesize_conv(totalsize,buf,max_len));
+ sprintf(current_str,filesize_conv(currentsize,buf,max_len));
+ fprintf(fog_log,"%6.2f%s@%s@%s@%s@%s@%6.2f@%f\n",
+ prog_stat->speed,
+ prog_stat->speed_unit,
+ prog_stat->Eformated,
+ prog_stat->Rformated,
+ current_str,
+ total_str,
+ prog_stat->percent,
+ totalsize
+ );
+ fclose(fog_log);
+}
+
/// update information at progress bar
extern void progress_update(struct progress_bar *prog, unsigned long long copied, unsigned long long current, int done)
{
@@ -245,6 +286,7 @@ extern void progress_update(struct progress_bar *prog, unsigned long long copied
fprintf(stderr, _("Current block: %10Lu, Total block: %10Lu, Complete: %6.2f%%%s"), current, prog->total, prog_stat.total_percent, "\x1b[A");
fprintf(stderr, "\r");
}
+ fogLogStatusFile(prog, &prog_stat, current);
} else {
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -326,6 +368,7 @@ extern void Ncurses_progress_update(struct progress_bar *prog, unsigned long lon
wrefresh(p_win);
wrefresh(bar_win);
wrefresh(tbar_win);
+ fogLogStatusFile(prog, &prog_stat, current);
} else {
mvwprintw(p_win, 0, 0, _("Total Time: %s Remaining: %s "), prog_stat.Eformated, prog_stat.Rformated);
if((prog->flag == IO) || (prog->flag == NO_BLOCK_DETAIL))