From: Khem Raj <raj.khem@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH] Replace LFS64 interfaces off64_t and lseek64
Date: Mon, 9 Jan 2023 11:42:13 -0800 [thread overview]
Message-ID: <CAMKF1spKBjcryWCXN9xHJ-n37JSBe+h0Wc6v=Scj_QxKkp0hsg@mail.gmail.com> (raw)
In-Reply-To: <20230109130539.62a15985@gandalf.local.home>
On Mon, Jan 9, 2023 at 10:05 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Fri, 6 Jan 2023 17:02:45 -0800
> Khem Raj <raj.khem@gmail.com> wrote:
>
> > Musl does not define these interfaces unless -D_LARGEFILE64_SOURCE is
> > defined and that too it is transitional until apps switch to using 64bit
> > off_t. We pass -D_LARGEFILE64_SOURCE in makefiles already therefore
> > original lseek and off_t are already 64bit
>
> I just tested this, and that's not true.
Right, I should have said we are already using 64bit functions. I did
not see it since in yocto
it was already being added by distro settings.
I think we need to add -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE and remove
-D_LARGEFILE64_SOURCE, I can update this in v2.
>
> static void pdie(const char *msg)
> {
> perror(msg);
> exit(-1);
> }
>
> int main (int argc, char **argv)
> {
> off_t off;
> int fd;
>
> argv0 = argv[0];
>
> if (argc < 2)
> usage();
>
> printf("off size = %zd\n", sizeof(off));
>
> fd = open(argv[1], O_RDONLY);
> if (fd < 0)
> pdie("open");
> off = lseek(fd, 0, SEEK_END);
> if (off < 0)
> pdie("lseek");
> printf("offset = %zd\n", off);
> return 0;
> }
>
> I compiled the above on a 32bit machine with:
>
> $ gcc -D_LARGEFILE64_SOURCE -o lseek lseek.c
> $ ./lseek big-file
>
> Where big-file was 6GBs, and I got this:
>
> off size = 4
> lseek: Value too large for defined data type
>
> The _LARGEFILE64_SOURCE just makes the 64 bit versions available. It does
> not convert the original ones.
>
> >
> > This fixes build with latest musl which has dropped LFS64 interfaces [1]
> >
> > [1] https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4i
> >
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > ---
>
> What we could do is add something like:
>
> #ifdef MUSL
> # define off64_t off_t
> # define lseek64 lseek
> [..]
> #endif
>
> in one of the headers to make it work with musl.
>
> -- Steve
next prev parent reply other threads:[~2023-01-09 19:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-07 1:02 [PATCH] Replace LFS64 interfaces off64_t and lseek64 Khem Raj
2023-01-09 18:05 ` Steven Rostedt
2023-01-09 18:10 ` Steven Rostedt
2023-01-09 19:42 ` Khem Raj [this message]
2023-01-09 20:46 ` Steven Rostedt
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='CAMKF1spKBjcryWCXN9xHJ-n37JSBe+h0Wc6v=Scj_QxKkp0hsg@mail.gmail.com' \
--to=raj.khem@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).