|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
|
Thread Tools | Display Modes |
|
|||
Test small C program in BSD OS
Hello.
I've written small program in C language. This program copies specified part of source file and saves it to destination file. I have GNU/Linux OS installed on my computer. Program works fine in Linux. It also works with big files (size >= 2 GiB) in 64-bit Linux. Help me please to test if program works in BSD OS (FreeBSD, NetBSD, OpenBSD), if you have this OS installed on your computer. Instruction on program usage and how to build it from source: https://gitlab.com/open_source/partcp Download ZIP archive with source code: https://gitlab.com/open_source/partc...zip?ref=master View source code: https://gitlab.com/open_source/partc...aster/partcp.c Program usage example: I want to copy 1234 bytes from file "source.bin" starting at offset 5678. Result must be saved to file "destination.bin". I will use this command: partcp source.bin 5678 1234 destination.bin Thank you. |
|
|||
Quote:
|
|
||||
Each of the Project's utilities may be slightly different, as each has a different provenance.
OpenBSD's dd(1) is based on NetBSD's, as OpenBSD was itself a fork of NetBSD, a little over 20 years ago. It has been continuously maintained, with the last revisions in support of OpenBSD's new pledge(2) security framework. Here's a link to the source code: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/bin/dd/ |
|
||||
If you add conv=sync:
Quote:
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. |
|
|||
Show me please full command line with given source_file, slice_offset, slice_length, destination_file as input values.
|
|
|||
Quote:
Code:
dd ibs=1 if=source_file of=destination_file skip=slice_offset count=slice_length Code:
partcp source_file slice_offset slice_length destination_file Code:
dd bs=high_value if=source_file of=destination_file skip=? count=? So we can't simply set them to slice_offset and slice_length, because in such case actual values will be: skip = slice_offset * high_value and count = slice_length * high_value, which is wrong. How do I correctly apply slice_offset and slice_length values here? Quote:
Can you show me full command line for "dd bs=4M ..." to exactly replace the following command? Code:
partcp source_file slice_offset slice_length destination_file |
|
|||
GNU coreutils' dd accepts the count_bytes and skip_bytes input flag to more easily allow processing portions of a file.
This feature is relatively new (added on Feb 2012). It allows to achieve fast (bs=4M) copy of arbitrary portion of a binary file using single commnad: Code:
dd if=source_file of=destination_file bs=4M iflag=count_bytes,skip_bytes skip=slice_offset count=slice_length ---------------------------------------- And what about BSD OSes? count_bytes and skip_bytes flags are not implemented in BSD variants of dd. In FreeBSD and NetBSD we can pipe tail into head. In OpenBSD we can use multiple calls to dd (see "Using a dd without the skip_bytes and count_bytes options"). It appears that there is no easy-to-use and fast byte-grabber under Unix. That's why I've written my program. |
|
||||
Quote:
|
|
|||
jggimi, thank you for your answer!
Updated project description on GitLab. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Small dmesg annoyance v10 ... | jb_daefo | FreeBSD Ports and Packages | 0 | 3rd January 2015 04:16 PM |
Small MPLS Test Network Built With OpenBSD | J65nko | News | 1 | 8th September 2013 07:40 PM |
firewalling with a small soekris appliance | wesley | OpenBSD Security | 2 | 6th June 2011 05:29 PM |
small guide on mutt & fdm | qmemo | Guides | 0 | 17th May 2011 10:54 PM |