Skip to contentSkip to conversation

man 2 stat

DISCUSSION Marius Gaubas 3 participants 9 messages Mar 9, 2014 – Mar 10, 2014 7 messages not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20140309202120.GA2447-/[email protected]

#2 lore raw
Quoted 1 line · Marius Gaubas

1. nlink_t st_nlink member goes after mode_t st_mode, not before @struct stat

Apologies, the correct statement is:

nlink_t st_nlink member is before mode_t st_mode, not after @struct stat
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20140309202449.GB2447-/[email protected]

#4 lore raw
Quoted 5 lines · Marius Gaubas
Quoted 1 line · Marius Gaubas

1. nlink_t st_nlink member goes after mode_t st_mode, not before @struct stat

Apologies, the correct statement is:

nlink_t st_nlink member is before mode_t st_mode, not after @struct stat

"I'm sorry HAL, what are are you trying to tell me?"

Translation: Could you _please_ communicate as though there are human beings on this list? What are you trying to tell us, and what is your evidence?

Thanks,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAKgNAkjcvRBqXC-Zemwap0Kt5PJLBL4SXA0ZOGYPOYSgqmvqoA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 9 lines · Michael Kerrisk (man-pages)
Quoted 5 lines · Marius Gaubas
Quoted 1 line · Marius Gaubas

1. nlink_t st_nlink member goes after mode_t st_mode, not before @struct stat

Apologies, the correct statement is:

nlink_t st_nlink member is before mode_t st_mode, not after @struct stat

"I'm sorry HAL, what are are you trying to tell me?"

Quoted 13 lines

Translation: Could you _please_ communicate as though there are human beings on this list? What are you trying to tell us, and what is your evidence?

Thanks,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

Hello Michael,

Please accept my apologies for a BOT-like e-mail.

My name is Marius Gaubas
(http://www.linkedin.com/pub/marius-gaubas/5b/63b/3a4).

The evicence is very clear. I invoke syscall:stat directly from assembly code and in the debugger I clearly see see that st_nlink (==2) goes before st_mode (==040700). It clearly makes sense: 8 8 4 8 is not aligned. The series reflects the sizes of the first for structure members. st_nlink/st_mode values are clearly specific to my test, I hope that's clear.

Kind regards,
Marius
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20140310100110.GA7155-/[email protected]

#8 lore raw

Am 10.03.2014 11:01, schrieb Marius Gaubas:

Quoted 24 lines · Michael Kerrisk (man-pages)
Quoted 9 lines · Marius Gaubas
Quoted 5 lines · Marius Gaubas
Quoted 1 line

1. nlink_t st_nlink member goes after mode_t st_mode, not before @struct stat

Apologies, the correct statement is:

nlink_t st_nlink member is before mode_t st_mode, not after @struct stat

"I'm sorry HAL, what are are you trying to tell me?"

Quoted 13 lines

Translation: Could you _please_ communicate as though there are human beings on this list? What are you trying to tell us, and what is your evidence?

Thanks,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
Quoted 7 lines

Hello Michael,

Please accept my apologies for a BOT-like e-mail.

My name is Marius Gaubas
(http://www.linkedin.com/pub/marius-gaubas/5b/63b/3a4).

hello nice to meet you.

Quoted 6 lines

The evicence is very clear. I invoke syscall:stat directly from assembly code and in the debugger I clearly see see that st_nlink (==2) goes before st_mode (==040700). It clearly makes sense: 8 8 4 8 is not aligned. The series reflects the sizes of the first for structure members. st_nlink/st_mode values are clearly specific to my test, I hope that's clear.

Ok,
you are talking about the sequence the fields are stored in the structure ?

re,
wh

Quoted 6 lines

Kind regards,
Marius
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 43 lines · walter harms

Am 10.03.2014 11:01, schrieb Marius Gaubas:

Quoted 24 lines · Michael Kerrisk (man-pages)
Quoted 9 lines · Marius Gaubas
Quoted 5 lines · Marius Gaubas
Quoted 1 line

1. nlink_t st_nlink member goes after mode_t st_mode, not before @struct stat

Apologies, the correct statement is:

nlink_t st_nlink member is before mode_t st_mode, not after @struct stat

"I'm sorry HAL, what are are you trying to tell me?"

Quoted 13 lines

Translation: Could you _please_ communicate as though there are human beings on this list? What are you trying to tell us, and what is your evidence?

Thanks,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
Quoted 7 lines

Hello Michael,

Please accept my apologies for a BOT-like e-mail.

My name is Marius Gaubas
(http://www.linkedin.com/pub/marius-gaubas/5b/63b/3a4).

hello nice to meet you.

Quoted 6 lines

The evicence is very clear. I invoke syscall:stat directly from assembly code and in the debugger I clearly see see that st_nlink (==2) goes before st_mode (==040700). It clearly makes sense: 8 8 4 8 is not aligned. The series reflects the sizes of the first for structure members. st_nlink/st_mode values are clearly specific to my test, I hope that's clear.

Quoted 12 lines

Ok,
you are talking about the sequence the fields are stored in the structure ?

re,
wh

Quoted 6 lines

Kind regards,
Marius
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Yes, st_mode and st_nlink are in a reverse order. Very simple to test from C with offsetof macro. I can quickly write it if it is needed for the prove.

M.
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw
In reply to a message not in the archive

Hello Marius!

Quoted 9 lines · Marius Gaubas
Quoted 6 lines · Michael Kerrisk (man-pages)
Quoted 5 lines · Marius Gaubas
Quoted 1 line · Marius Gaubas

1. nlink_t st_nlink member goes after mode_t st_mode, not before @struct stat

Apologies, the correct statement is:

nlink_t st_nlink member is before mode_t st_mode, not after @struct stat

Please accept my apologies for a BOT-like e-mail.

;-). Accepted.

Quoted 9 lines

My name is Marius Gaubas
(http://www.linkedin.com/pub/marius-gaubas/5b/63b/3a4).

The evicence is very clear. I invoke syscall:stat directly from assembly code and in the debugger I clearly see see that st_nlink (==2) goes before st_mode (==040700). It clearly makes sense: 8 8 4 8 is not aligned. The series reflects the sizes of the first for structure members. st_nlink/st_mode values are clearly specific to my test, I hope that's clear.

It's clear, but it's also a very narrow field of view. On the particular architecture (I guess x86-64) you are using, it appears to be true. But, there is much more to consider. See, for example <bits/stat.h> and the kernel source file arch/x86/include/uapi/asm/stat.h. On x86-32, the order is as shown in the man page; it looks as though the same is true on ARM. Furthermore, on various architectures, there are padding fields at different places, and glibc under the covers does a lot of magic to present something sane (and portable across kernel versions) to user space.

Now, trying to document all of the architecture-specific details in the man page is difficult, and would probably be confusing to the reader. But, a warning to the reader is probably in order. I've added the following text below the structure definition:

Note: the order of fields in the stat structure varies somewhat
across architectures. In addition, the definition above does
not show the padding bytes that may be present between some
fields on various architectures. Consult the the glibc and
kernel source code if you need to know the details.

Seem okay to you?

Thanks,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAKgNAkiNYcL2rcmRm=PTGC76PhevQaYgZMERg9tYkmszmsx8+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#13 lore raw
Quoted 47 lines · Michael Kerrisk (man-pages)

Hello Marius!

Quoted 9 lines · Marius Gaubas
Quoted 6 lines · Michael Kerrisk (man-pages)
Quoted 5 lines · Marius Gaubas
Quoted 1 line · Marius Gaubas

1. nlink_t st_nlink member goes after mode_t st_mode, not before @struct stat

Apologies, the correct statement is:

nlink_t st_nlink member is before mode_t st_mode, not after @struct stat

Please accept my apologies for a BOT-like e-mail.

;-). Accepted.

Quoted 9 lines

My name is Marius Gaubas
(http://www.linkedin.com/pub/marius-gaubas/5b/63b/3a4).

The evicence is very clear. I invoke syscall:stat directly from assembly code and in the debugger I clearly see see that st_nlink (==2) goes before st_mode (==040700). It clearly makes sense: 8 8 4 8 is not aligned. The series reflects the sizes of the first for structure members. st_nlink/st_mode values are clearly specific to my test, I hope that's clear.

It's clear, but it's also a very narrow field of view. On the particular architecture (I guess x86-64) you are using, it appears to be true. But, there is much more to consider. See, for example <bits/stat.h> and the kernel source file arch/x86/include/uapi/asm/stat.h. On x86-32, the order is as shown in the man page; it looks as though the same is true on ARM. Furthermore, on various architectures, there are padding fields at different places, and glibc under the covers does a lot of magic to present something sane (and portable across kernel versions) to user space.

Now, trying to document all of the architecture-specific details in the man page is difficult, and would probably be confusing to the reader. But, a warning to the reader is probably in order. I've added the following text below the structure definition:

Note: the order of fields in the stat structure varies somewhat
across architectures. In addition, the definition above does
not show the padding bytes that may be present between some
fields on various architectures. Consult the the glibc and
kernel source code if you need to know the details.

Quoted 10 lines

Seem okay to you?

Thanks,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

Hello Michael,

I do appreciate your point. And I agree it is very valid. Man page is not and should not become an overloaded document with all the platform specific caveats. But I also see it valuable to clearly explain where the document is not absolutely precise and what sources should be further consulted for the details.

Your proposed change looks perfect to me.

Thank you very much for you time!

Kind regards,
Marius
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20140310111526.GC7263-/[email protected]

#15 lore raw
Quoted 19 lines
Quoted 5 lines

Now, trying to document all of the architecture-specific details in the man page is difficult, and would probably be confusing to the reader. But, a warning to the reader is probably in order. I've added the following text below the structure definition:

Quoted 7 lines

Note: the order of fields in the stat structure varies somewhat
across architectures. In addition, the definition above does
not show the padding bytes that may be present between some
fields on various architectures. Consult the the glibc and
kernel source code if you need to know the details.

Seem okay to you?

I do appreciate your point. And I agree it is very valid. Man page is not and should not become an overloaded document with all the platform specific caveats. But I also see it valuable to clearly explain where the document is not absolutely precise and what sources should be further consulted for the details.

Quoted 3 lines

Your proposed change looks perfect to me.

Thank you very much for you time!

Your welcome. Thanks for the report.

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html