Re: Issue in man page getdents.2

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

 



Hi Helge,

On Wed, Nov 01, 2023 at 03:40:50PM +0000, Helge Kreutzmann wrote:
> Hello Alejandro,
> Am Wed, Nov 01, 2023 at 04:28:12PM +0100 schrieb Alejandro Colomar:
> > Hi Helge,
> > 
> > On Wed, Nov 01, 2023 at 02:02:10PM +0000, Helge Kreutzmann wrote:
> > > Without further ado, the following was found:
> > > 
> > > Issue:    Zero padding byte →  null padding byte?
> > > 
> > > msgid ""
> > > "struct linux_dirent {\n"
> > > "    unsigned long  d_ino;     /* Inode number */\n"
> > > "    unsigned long  d_off;     /* Offset to next I<linux_dirent> */\n"
> > > "    unsigned short d_reclen;  /* Length of this I<linux_dirent> */\n"
> > > "    char           d_name[];  /* Filename (null-terminated) */\n"
> > > "                      /* length is actually (d_reclen - 2 -\n"
> > > "                         offsetof(struct linux_dirent, d_name)) */\n"
> > > "    /*\n"
> > > "    char           pad;       // Zero padding byte\n"
> > 
> > Both seem good to me.  Why not zero?
> 
> I'm not a programmer. But I thought the term was null? If this is not
> the case, then disregard my proposal.

It isn't simple.  Here's an overview of all the similar terms:
<https://lore.kernel.org/linux-man/ZU0eKrZprM5HSGt0@debian/>


-  NULL is a null pointer constant (as well as 0 is another null pointer
   constant; but don't use 0 for pointers, please).

-  A null pointer is a more generic term that includes a run-time null
   pointer as well. 

-  The null byte is 0.

-  The null character, '\0', is composed of a null byte.

-  The null wide character, L'\0' is composed of several null bytes.

-  NUL is the ASCII name of the null byte, or maybe is it null character
   here?  It's a bit muddy.


For padding, you'd use either null bytes, or equivalently, 0s, or zeros.

Cheers,
Alex

> 
> Greetings
> 
>          Helge
> 
> -- 
>       Dr. Helge Kreutzmann                     debian@xxxxxxxxxxxxx
>            Dipl.-Phys.                   http://www.helgefjell.de/debian.php
>         64bit GNU powered                     gpg signed mail preferred
>            Help keep free software "libre": http://www.ffii.de/



-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux