Re: [PATCH] Replace LFS64 interfaces off64_t and lseek64

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

 



On Mon, Jan 9, 2023 at 10:05 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> On Fri,  6 Jan 2023 17:02:45 -0800
> Khem Raj <raj.khem@xxxxxxxxx> 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@xxxxxxxxx>
> > ---
>
> 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



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux