poke-devel
[Top][All Lists]
Advanced

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

Re: [RFC] redoxfs.pk: Pickle for RedoxFS file system


From: Jose E. Marchesi
Subject: Re: [RFC] redoxfs.pk: Pickle for RedoxFS file system
Date: Fri, 18 Dec 2020 18:10:06 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> /* Node pretty-printer
>  *
>  * Prints the contents of a `RedoxFS_Node` in a readable fashion.
>  * To increase readability, only non-empty extents are get printed before any
>  * other fields. By default, extents are get printed from first one to last
>  * one by default, but this can be changed by passing 1 in `reverse` argument.
>  */
> fun redoxfs_nprint = (RedoxFS_Node n, int reverse = 0) void:

If you turn this into a proper method pretty printer (_print) in the
type RedoxFS_Node, then you can omit the `reverse' argument: see comment
below.

>   {
>     print ("#<\n  extents = [\n");
>
>     var f = reverse ? n.extents'length : 0UL;  /* first */
>     var l = reverse ? 0UL : n.extents'length;  /* last  */
>
>     while (f != l) {
>       if (reverse)
>         --f;
>
>       var e = n.extents[f];
>
>       if (!e.empty)
>         printf ("    .[%u64d]={block=%v, length=%v}\n", f, e.block, e.length);

Looks like the above line should go to the pretty printer (_print) of
RedoxFS_Extent, including the handling of !empty.

The poke user could then do:

(poke) var fs = RedoxFS_Node @ WHEREVER
(poke) fs
#<
  extents=[#<...>, #<...>, ...],
  FILE
  ...
>

If the user wanted to look at the extents in reverse order:

(poke) areverse (fs.extents)
[#<...>, #<...>, ...]

(Yes I know someone has to write an `areverse' function in the std
library :))

>
>       if (!reverse)
>         ++f;
>     }
>
>     var mtype =
>       n.issymlink ? "FILE | SYM"
>       : n.isfile ? "FILE"
>       : n.isdir ? "DIR"
>       : "" ;
>
>     printf (
>       "  ],\n  mode=%s | %u12o,\n  uid=%u32d,\n  gid=%u32d,\n  ctime=%u64d (",
>       mtype, n.mode & RedoxFS_MODE_PERM, n.uid, n.gid, n.ctime);
>     ptime (n.ctime);
>     printf ("),\n  ctime_nsec=%u64d,\n  mtime=%u64d (", n.ctime_nsec, 
> n.mtime);
>     ptime (n.mtime);
>     printf ("),\n  mtime_nsec=%u64d,\n  atime=%u64d (", n.mtime_nsec, 
> n.atime);
>     ptime (n.atime);
>     printf (
>       "),\n  atime_nsec=%u64d,\n  name=%s,\n", n.atime_nsec, catos (n.name));
>     printf ("  parent=%v,\n  next=%v,\n>\n", n.parent, n.next);
>   }



reply via email to

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