All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
To: "Michael Kerrisk (man-pages)"
	<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Jan Chaloupka <jchaloup-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Siddhesh Poyarekar
	<siddhesh-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Rich Felker <dalias-8zAoT0mYgF4@public.gmane.org>,
	roland-/Z5OmTQCD9xF6kxbq+BtvQ@public.gmane.org
Subject: Re: statfs.2: f_spare[4]  or f_spare[5]
Date: Sun, 15 Feb 2015 05:08:14 -0500	[thread overview]
Message-ID: <20150215100814.GD32251@vapier> (raw)
In-Reply-To: <54D33A66.1080908-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2838 bytes --]

On 05 Feb 2015 10:39, Michael Kerrisk (man-pages) wrote:
> Rich Felker a while back also wrote about problems in the man page:
> http://thread.gmane.org/gmane.linux.man/6749
> 
> [[
> The man page for statfs(2) is using macros which are glibc
> implementation internals (not part of the public interface) for
> defining struct statfs. This leads programmers to believe they should
> use these macros in applications (a cast to __SWORD_TYPE has recently
> appeared in util-linux; see link [1] below) and __SWORD_TYPE isn't
> even the correct type on glibc/x32.
> 
> Note that glibc also has the signedness of these members wrong; in the
> kernel, they're rightfully unsigned for 32-bit and only signed on
> 64-bit (where it doesn't matter). musl does not have this mismatch; we
> use unsigned types where they make sense (e.g. storing unsigned
> filesystem magic numbers that don't fit in signed 32-bit).
> 
> Since the types of these fields are such a mess, I think the man page
> should refrain from documenting specific types, and should include
> advice on safe usage, including how to safely compare f_type -- on
> glibc, the value will wrongly be negative for many filesystems, and
> although default integer promotions will fix this for direct
> comparison with the fs magic constants, the safe way to use f_type
> seems to be explicitly casting it to uint32_t.
> ]]
> 
> So, this all seems a glibc mess to me. However,perhaps I'm not 
> understanding something. What is the glibc expectation, regarding 
> how people should work with these fields? I mean, suppose one wants
> to copy one of the __fsword_t to a local variable, what type is
> one supposed to do? What I'd kind of hope for is publicly export
> system data(s). But lacking that, what does one do? It appears
> that "unsigned int" should do the job. What about the following 
> text for the man page:
> 
>     The  __fsword_t  type  used  for  various  fields in the statfs
>     structure definition is a glibc internal type, not intended for
>     public use.  This leaves the programmer in a bit of a conundrum
>     when trying to copy or compare these fields to local  variables
>     in  a  program.  Using unsigned int for such variables suffices
>     on most systems.

looking at the history of the file in glibc (which stretches back to at least 
1995), i think trying to deal with differences across arches/ABIs/OSs/LFS 
settings has lead it to be macro heavy in favor of the maintainers rather than 
directly considering the usage by developers.  especially since the function 
isn't documented in the glibc manual ... it's being provided more as a low 
level/historical requirement rather than a desire to get it right.

maybe Roland can comment since he's the author of some of these commits :).
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2015-02-15 10:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-31 21:26 statfs.2: f_spare[4] or f_spare[5] Jan Chaloupka
     [not found] ` <5453FE6F.3010501-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-10-31 21:44   ` Jan Chaloupka
     [not found]     ` <545402A1.30404-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-01  2:40       ` Siddhesh Poyarekar
2014-11-01  3:56   ` Mike Frysinger
     [not found]     ` <20141101035621.GH26840-eAEk4k+vi/E8xmjh+jFwDmGXanvQGlWp@public.gmane.org>
2014-11-01 12:00       ` Jan Chaloupka
     [not found]         ` <5454CB4C.6000805-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-11-01 15:36           ` Mike Frysinger
     [not found]             ` <20141101153635.GB21263-eAEk4k+vi/E8xmjh+jFwDmGXanvQGlWp@public.gmane.org>
2015-02-05  9:39               ` Michael Kerrisk (man-pages)
     [not found]                 ` <54D33A66.1080908-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-02-15 10:08                   ` Mike Frysinger [this message]
2015-02-21  7:56                     ` Michael Kerrisk (man-pages)
     [not found]                       ` <54E83A3B.5030200-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-06-05 22:44                         ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150215100814.GD32251@vapier \
    --to=vapier-abrp7r+bbdudnm+yrofe0a@public.gmane.org \
    --cc=dalias-8zAoT0mYgF4@public.gmane.org \
    --cc=jchaloup-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=roland-/Z5OmTQCD9xF6kxbq+BtvQ@public.gmane.org \
    --cc=siddhesh-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.