tjohansen14 / diskscrub

Automatically exported from code.google.com/p/diskscrub
GNU General Public License v2.0
0 stars 0 forks source link

add -p custom option #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Suggestion from Peter Hyman:

   permit scrub to accept a string to write to a file/device instead of
   predefined ones.
   Add a pattern definition `custom` which will accept a string on the
   command line from the user.
   Permit ASCII characters and/or Hex as well in quotes.
   Program will parse input and write data iteratively to a file/device.
   An example command line for ASCII:

   scrub -p custom "WRITE this DATA" file
   which will write `WRITE this DATA' through the entire file

   scrub -p custom "WRITE ASCII and hex 0xff0xaa" file
   which will write `WRITE ASCII and hex ffaa' through the entire file where
   ffaa is char(255) and char(170)

   0x## will trigger a hex conversion anywhere in the string

Original issue reported on code.google.com by garlick....@gmail.com on 2 Feb 2012 at 10:03

GoogleCodeExporter commented 8 years ago

Original comment by garlick....@gmail.com on 2 Feb 2012 at 10:05

GoogleCodeExporter commented 8 years ago
On Fri, Feb 03, 2012 at 11:29:05AM -0800, Peter Hyman wrote:
>    See NEWS for update.
>
>    Please test some. I think it's pretty good. Enjoy the weekend!

Original comment by garlick....@gmail.com on 17 Apr 2012 at 5:40

Attachments:

GoogleCodeExporter commented 8 years ago
Changes to scrub-2.5.0.patch.gz:
- Removed issue 9 changes unrelated to this set of changes
- For the moment dropped NEWS, META, ChangeLog 
- Updated to apply to current git tree.

Review comments to follow.

Original comment by garlick....@gmail.com on 17 Apr 2012 at 6:11

Attachments:

GoogleCodeExporter commented 8 years ago
I think we could simplify this patch in the following ways:

- drop -A -H options and allow --pattern custom="string"
- in string, allow \nnn (octal) and \xnn (hex) constants as with C strings
- when seq_lookup() encounters custom="string", have it malloc a new pattern 
struct
called "custom" (one pass, type PAT_NORMAL) and return it.
- expose a pattern_cleanup() function in pattern.c to free a created sequence 
if any and call it from scrub.c on successful termination.
- no special case in pat2str(), just use PAT_NORMAL handling

This would avoid changing the options and would localize your changes to 
pattern.c.

What do you think?

Original comment by garlick....@gmail.com on 17 Apr 2012 at 6:33

GoogleCodeExporter commented 8 years ago
Whoops, I meant create a new sequence_t not a new pattern.
The sequence would have one pattern.
There's a name mismatch between data structures and option names :-(

Original comment by garlick....@gmail.com on 17 Apr 2012 at 6:37

GoogleCodeExporter commented 8 years ago
OK, I couldn't leave it alone.  What do you think of this way of doing it?

Original comment by garlick....@gmail.com on 17 Apr 2012 at 10:27

Attachments:

GoogleCodeExporter commented 8 years ago
THis patch evolved a bit and was committed for 2.5.0.
Closing the issue for now.  Please open a new issue if you have
any issues with the implementation.

        commit 183c21a8f400b3af4ab76fce1e753ff7dd944bb7
        Author: Jim Garlick <garlick.jim@gmail.com>
        Date:   Wed Apr 18 10:16:13 2012 -0700

            Change title of custom pattern

        commit 2e45eab8cbd5f682dfb2ff7873a3935724af0d11
        Author: Jim Garlick <garlick.jim@gmail.com>
        Date:   Tue Apr 17 15:33:47 2012 -0700

            Add custom pattern capability [Peter Hyman] (issue 11)

            Allow scrub --pattern=custom="string" (issue 11) [Peter Hyman]
            Allow C style numerical escapes in string: \nnn (octal) and \xnn
            (hex).  This is a single-pass sequence with a custom pattern.

Original comment by garlick....@gmail.com on 24 Apr 2012 at 8:26