poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] New pickle for TAR files.


From: Mohammad-Reza Nabipoor
Subject: Re: [PATCH] New pickle for TAR files.
Date: Mon, 26 Jun 2023 21:56:22 +0200

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]