Codebase list dcfldd / 96651ca
Update upstream source from tag 'upstream/1.9' Update to upstream version '1.9' with Debian dir 17f8173afae9645be82dd83a13a06295e25e6cdc Joao Eriberto Mota Filho 1 year, 2 months ago
15 changed file(s) with 91 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
0 2023-02-08 Joao Eriberto Mota Filho <eriberto@eriberto.pro.br>
1 Version 1.9
2
3 [ Tibor Szolnoki ]
4
5 * Added support for writing to output only if destination block content
6 differs ('diffwr' option).
7
8 [ David Polverari ]
9
10 * Added bash completion for diffwr.
11 * Minor fixes in manpage and help.
12 * Minor optimizations in source code.
13
014 2022-10-17 Joao Eriberto Mota Filho <eriberto@eriberto.pro.br>
115 Version 1.8
216
0 Version 1.9
1 -----------
2
3 New option: diffwr.
4
05 Version 1.5
16 -----------
27
2020
2121 AC_PREREQ([2.69])
2222
23 AC_INIT([dcfldd],[1.8],[https://github.com/resurrecting-open-source-projects/dcfldd/issues])
23 AC_INIT([dcfldd],[1.9],[https://github.com/resurrecting-open-source-projects/dcfldd/issues])
2424 AC_CONFIG_SRCDIR(src/dcfldd.c)
2525 AM_INIT_AUTOMAKE
2626
00 # bash completion for dcfldd -*- shell-script -*-
11 # Copyright 2017-2020 Joao Eriberto Mota Filho <eriberto@debian.org>
2 # Copyright 2022 David Polverari <david.polverari@gmail.com>
23 # Version: 20200113
34 # Based in dd completion script.
45
4041 COMPREPLY=( $( compgen -W 'if of' -- "$cur" ) )
4142 return 0
4243 ;;
44 diffwr=*)
45 cur=${cur#*=}
46 COMPREPLY=( $( compgen -W 'on off' -- "$cur") )
47 return 0
48 ;;
4349 esac
4450
4551 _expand || return 0
4955 textpattern errlog hash md5log sha1log sha256log sha384log
5056 sha512log hashwindow hashconv hashformat totalhashformat
5157 status statusinterval sizeprobe split splitformat vf
52 verifylog' -S '=' -- "$cur" ) )
58 verifylog diffwr' -S '=' -- "$cur" ) )
5359 } &&
5460 complete -F _dcfldd -o nospace dcfldd
1515 #--------------------------------------------------------
1616
1717 # Put here all data for your first manpage (in T2M lines)
18 T2M_DATE="17 Oct 2022"
18 T2M_DATE="08 Feb 2023"
1919 T2M_NAME=dcfldd
20 T2M_VERSION=1.8
20 T2M_VERSION=1.9
2121 T2M_LEVEL=1
2222 T2M_DESC="enhanced version of dd for forensics and security"
2323 create-man
00 .\" Text automatically generated by txt2man
1 .TH dcfldd 1 "17 Oct 2022" "dcfldd-1.8" "enhanced version of dd for forensics and security"
1 .TH dcfldd 1 "08 Feb 2023" "dcfldd-1.9" "enhanced version of dd for forensics and security"
22 .SH NAME
33 \fBdcfldd \fP- enhanced version of dd for forensics and security
44 \fB
206206 Exec and write verify results to process COMMAND.
207207 .TP
208208 .B
209 diffwr=[on|off]
210 Only write to output if destination block content differs. This operation applies
211 to any of=FILE that follows (diffwr= must be put before any of=).
212 .TP
213 .B
209214 \fB--help\fP
210215 Display a help page and exit.
211216 .TP
9696 vf=FILE Verify that FILE matches the specified input.
9797 verifylog=FILE Send verify results to FILE instead of stderr.
9898 verifylog:=COMMAND Exec and write verify results to process COMMAND.
99 diffwr=[on|off] Only write to output if destination block content differs. This operation applies
100 to any of=FILE that follows (diffwr= must be put before any of=).
99101 --help Display a help page and exit.
100102 --version Output version information and exit.
101103
66 Copyright 2008 David Loveall <dave@loveall.org>
77 Copyright 2012 Miah Gregory <mace@debian.org>
88 Copyright 2014 Vangelis Koukis <vkoukis@gmail.com>
9 Copyright 2022 David Polverari <david.polverari@gmail.com>
10 Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com>
911
1012 This program is free software; you can redistribute it and/or modify
1113 it under the terms of the GNU General Public License as published by
132134 int do_hash = 0;
133135 int do_verify = 0;
134136 int do_split = 0;
137 int do_diffwr = 0;
135138
136139 hashconv_t hashconv = DEFAULT_HASHCONV;
137140
201204 vf=FILE verify that FILE matches the specified input\n\
202205 verifylog=FILE send verify results to FILE instead of stderr\n\
203206 verifylog:=COMMAND exec and write verify results to process COMMAND\n\
207 diffwr=[on|off] only write to output if destination block content differs\n\
204208 \n\
205209 --help display this help and exit\n\
206210 --version output version information and exit\n\
578582 if (invalid)
579583 probe = PROBE_NONE;
580584 }
585 } else if (STREQ(name, "diffwr")) {
586 if (STREQ(val, "off"))
587 do_diffwr = 0;
588 else if (STREQ(val, "on"))
589 do_diffwr = 1;
581590 } else {
582591 int invalid = 0;
583592 uintmax_t n = parse_integer(val, &invalid);
55 /* Copyright 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
66 Copyright 2008 David Loveall <dave@loveall.org>
77 Copyright 2017-2019 Joao Eriberto Mota Filho <eriberto@eriberto.pro.br>
8 Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com>
89
910 This program is free software; you can redistribute it and/or modify
1011 it under the terms of the GNU General Public License as published by
143144 extern int do_hash;
144145 extern int do_verify;
145146 extern int do_status;
147 extern int do_diffwr;
146148
147149 extern int char_is_saved;
148150 extern unsigned char saved_char;
00 /* full-write.c -- an interface to write that retries after interrupts
1 Copyright (C) 1993, 1994, 1997, 1998, 2000 Free Software Foundation, Inc.
1 Copyright 1993, 1994, 1997, 1998, 2000 Free Software Foundation, Inc.
2 Copyright 2022 David Polverari <david.polverari@gmail.com>
3 Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com>
24
35 This program is free software; you can redistribute it and/or modify
46 it under the terms of the GNU General Public License as published by
2426 #endif
2527
2628 #include <sys/types.h>
29 #include "safe-read.h"
2730
2831 #if HAVE_UNISTD_H
2932 # include <unistd.h>
3841 Return LEN upon success, write's (negative) error code otherwise. */
3942
4043 int
41 full_write (int desc, const char *ptr, size_t len)
44 full_write (int desc, const char *ptr, size_t len, int diffwr)
4245 {
4346 int total_written;
4447
4548 total_written = 0;
4649 while (len > 0)
4750 {
48 int written = write (desc, ptr, len);
51 int written = 0;
52 if (diffwr) { /* Check destination block content is same as the buffer */
53 char *rptr = NULL;
54 off_t pos = lseek(desc, 0, SEEK_CUR);
55 if ((pos >= 0) && (rptr = malloc(len))) {
56 int rlen = safe_read(desc, rptr, len);
57 if ((rlen <= 0) || (rlen != len) || (memcmp(rptr, ptr, len))) {
58 free(rptr);
59 lseek(desc, pos, SEEK_SET);
60 } else {
61 written = len;
62 }
63 }
64 }
65 if (written <= 0) {
66 written = write (desc, ptr, len);
67 }
4968 /* write on an old Slackware Linux 1.2.13 returns zero when
5069 I try to write more data than there is room on a floppy disk.
5170 This puts dd into an infinite loop. Reproduce with
22 * By Nicholas Harbour
33 */
44
5 /* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
5 /* Copyright 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
6 Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com>
67
78 This program is free software; you can redistribute it and/or modify
89 it under the terms of the GNU General Public License as published by
2324 #ifndef FULL_WRITE_H
2425 #define FULL_WRITE_H
2526
26 int full_write(int, const char *, size_t);
27 int full_write(int, const char *, size_t, int diffwr);
2728
2829 #endif /* FULL_WRITE_H */
44
55 /* Copyright 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
66 Copyright 2008 David Loveall <dave@loveall.org>
7 Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com>
78
89 This program is free software; you can redistribute it and/or modify
910 it under the terms of the GNU General Public License as published by
4445 int fd;
4546 int opts
4647 = (O_CREAT
47 | (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC));
48 | ((seek_records || do_diffwr || (conversions_mask & C_NOTRUNC)) ? 0 : O_TRUNC));
4849
4950 /* Open the output file with *read* access only if we might
50 need to read to satisfy a `seek=' request. If we can't read
51 need to read to satisfy a `seek=' or "diffwr=on" request. If we can't read
5152 the file, go ahead with write-only access; it might work. */
52 if ((! seek_records
53 if ((! (seek_records || do_diffwr)
5354 || (fd = open(filename, O_RDWR | opts, perms)) < 0)
5455 && (fd = open(filename, O_WRONLY | opts, perms)) < 0)
5556 {
120121
121122 ptr->next = NULL;
122123 ptr->type = type;
124 ptr->diffwr = do_diffwr;
123125
124126 switch (type) {
125127 case SINGLE_FILE:
129131 ptr->type = SINGLE_FILE;
130132 ptr->stream = va_arg(ap, FILE *);
131133 ptr->data.fd = fileno(ptr->stream);
134 ptr->diffwr = 0;
132135 break;
133136 case SPLIT_FILE:
134137 split = malloc(sizeof *split);
154157 nwritten = 0;
155158 switch (ptr->type) {
156159 case SINGLE_FILE:
157 nwritten = full_write(ptr->data.fd, buf, len);
160 nwritten = full_write(ptr->data.fd, buf, len, ptr->diffwr);
158161 break;
159162 case SPLIT_FILE:
160 nwritten = split_write(ptr->data.split, buf, len);
163 nwritten = split_write(ptr->data.split, buf, len, ptr->diffwr);
161164 break;
162165 }
163166 if (nwritten < len)
44
55 /* Copyright 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
66 Copyright 2008 David Loveall <dave@loveall.org>
7 Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com>
78
89 This program is free software; you can redistribute it and/or modify
910 it under the terms of the GNU General Public License as published by
4546 int fd;
4647 split_t *split;
4748 } data;
49 int diffwr;
4850 } outputlist_t;
4951
5052 extern outputlist_t *outputlist;
66 Copyright 2012 Miah Gregory <mace@debian.org>
77 Copyright 2015-2019 Joao Eriberto Mota Filho <eriberto@eriberto.pro.br>
88 Copyright 2019 Bernhard Übelacker <bernhardu@mailbox.org>
9 Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com>
910
1011 This program is free software; you can redistribute it and/or modify
1112 it under the terms of the GNU General Public License as published by
139140 free(fname);
140141 }
141142
142 int split_write(split_t *split, const char *buf, size_t len)
143 int split_write(split_t *split, const char *buf, size_t len, int diffwr)
143144 {
144145 off_t left = split->max_bytes - split->curr_bytes;
145146 int nwritten = 0;
150151 }
151152
152153 if (len <= left) {
153 nwritten = full_write(split->currfd, buf, len);
154 nwritten = full_write(split->currfd, buf, len, diffwr);
154155 split->total_bytes += nwritten;
155156 split->curr_bytes += nwritten;
156157 } else {
157 nwritten = full_write(split->currfd, buf, left);
158 nwritten = full_write(split->currfd, buf, left, diffwr);
158159 split->total_bytes += nwritten;
159160 split->curr_bytes += nwritten;
160 nwritten += split_write(split, &buf[nwritten], len - nwritten);
161 nwritten += split_write(split, &buf[nwritten], len - nwritten, diffwr);
161162 }
162163
163164 return nwritten;
11 * dcfldd - The Enhanced Forensic DD
22 * By Nicholas Harbour
33 */
4 /* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
4 /* Copyright 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
5 Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com>
56
67 This program is free software; you can redistribute it and/or modify
78 it under the terms of the GNU General Public License as published by
3536 char *format;
3637 } split_t;
3738
38 extern int split_write(split_t *, const char *, size_t);
39 extern int split_write(split_t *, const char *, size_t, int diffwr);
3940
4041 #endif /* SPLIT_H */