[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] New pickle for TAR files.
From: |
Kostas Chasialis |
Subject: |
Re: [PATCH] New pickle for TAR files. |
Date: |
Sat, 5 Aug 2023 20:31:33 +0300 |
Hello Mohammad!
No problem for the last answer.
I am also sorry for my late reply.
Thank you for your comments.
I have added 2 tests in the patch, one representing an empty tar file and one
with some non-empty files and directories.
The command I used was: tar -cvf <directory>.tar directory
Please find attached the new patch.
Thanks.
0001-New-pickle-for-tar-files.patch
Description: Binary data
> On 26 Jun 2023, at 10:56 PM, Mohammad-Reza Nabipoor <mnabipoor@gnu.org> wrote:
>
>
> Hi Kostas!
>
> Sorry for the late answer.
> Thanks for the patch.
>
> Also thanks to your patch, I tried to use `pk-bin2poke' and realized
> that we're shipping a broken `pk-bin2poke'! I fixed it.
> So please reinstall poke from master (when Jose approved the patches).
>
> Back to the pickle ...
>
> It's a good idea to have tests for each pickle; you can find a bunch of
> tests in `testsuite/poke.pickles/` directory.
>
> `testsuite/poke.pickles/btf-test.pk` is a very good example (thanks to
> David Faust).
> The array is generated by `pk-bin2poke' script. What you can do is to
> create a bunch of tar files:
>
> - An empty tarball
> - A tarball with a single empty file
> - A tarball with a bunch of small files with different names (short
> and long names), different size, different modes, etc.
>
> And if you want to be more nice to people, you can also put the commands
> that you've used to create each tarball in the comments (in order to make
> future development of tests easier).
> wants to extend the tests
>
> We can have more than one test for this pickle (one for each sample
> tarball), like
> - `testsuite/poke.pickles/tar-1-test.pk'
> - `testsuite/poke.pickles/tar-2-test.pk'
> - `testsuite/poke.pickles/tar-3-test.pk'
>
>
> new file mode 100644
> index 00000000..224f2bdc
> --- /dev/null
> +++ b/pickles/tar.px
>
>
> s/tar.px/tar.pk/ :)
>
>
> @@ -0,0 +1,211 @@
> +/* tar.pk - TAR implementation for GNU poke. */
> +
> +/* Copyright (C) 2019, 2020, 2021, 2022, 2023 Jose E. Marchesi. */
>
>
> You have to put your name here and the year 2023.
>
>
> +/* This file contains a description of tar files (PAX). */
>
>
> It is always useful to put some links to documents that specify the protocol.
> Links like:
> - https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html
> "EXTENDED DESCRIPTION" section.
> - https://www.mkssoftware.com/docs/man4/pax.4.asp
> - ...
>
>
> +
> +type TAR_Thdr =
> + struct
> + {
> + uint<8>[100] name_chars; /* File name. */
> + uint<8>[8] mode_chars; /* File mode. */
> + uint<8>[8] uid_chars; /* Owner's numeric user ID. */
> + uint<8>[8] gid_chars; /* Group's numeric user ID. */
> + uint<8>[12] size_chars; /* File size in bytes. */
> + uint<8>[12] mtime_chars; /* Last modification time in numeric Unix time
> format. */
> + uint<8>[8] chksum_chars; /* Checksum for header record. */
> + uint<8> typeflag_char : typeflag_char in ['0', '\0', '1', '2', '3', '4',
> '5', '6', '7', 'x', 'g']; /* Link indicator (file type). */
>
>
> You can use define variables for typeflag, something like this:
>
> ```poke
> var TAR_TypeFlag_Regular1 = 0UB,
> TAR_TypeFlag_Regular2 = '0',
> TAR_TypeFlag_Link = '1',
> TAR_TypeFlag_Symlink = '2',
> TAR_TypeFlag_CharDev = '3',
> /* ... */ ;
>
> var TAR_VALID_TYPEFLAGS = [
> TAR_TypeFlag_Regular1,
> TAR_TypeFlag_Regular2,
> TAR_TypeFlag_Link,
> TAR_TypeFlag_Symlink,
> TAR_TypeFlag_CharDev,
> /* ... */,
> ];
> ```
>
> And then use this constriant: `typeflag in TAR_VALID_TYPEFLAGS`.
>
>
> Thanks enough for now :)
> I hope you send the 2nd version soon!
>
> Regards,
> Mohammad-Reza
- Re: [PATCH] New pickle for TAR files.,
Kostas Chasialis <=