All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolaus Rath <Nikolaus@rath.org>
To: fuse-devel@lists.sourceforge.net,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Cc: Miklos Szeredi <mszeredi@redhat.com>
Subject: Handling of 32/64 bit off_t by getdents64()
Date: Wed, 27 Nov 2019 09:33:27 +0000	[thread overview]
Message-ID: <8736e9d5p4.fsf@vostro.rath.org> (raw)

Hello,

For filesystems like ext4, the d_off values returned by getdents64()
seem to depend on the kind of process that issues the syscall.

For example, if I compile test program with -m32 I get:

$ ./readdir32 
--------------- nread=616 ---------------
inode#    file type  d_reclen  d_off   d_name
32253478  ???          40  770981411  test_readlog.py
32260181  ???          24  776189020  ..
[...]

If I compile for 64 bit, I get:

$ ./readdir64 
--------------- nread=616 ---------------
inode#    file type  d_reclen  d_off   d_name
32253478  ???          40 3311339950278905338  test_readlog.py
32260181  ???          24 3333706456980390508  ..
[...]

This is despite d_off being declared as ino64_t in the linux_dirent64
struct.


This is presumably intentional, because (again as far as I can tell), if
getdents64 returns a full 64 bit value for a 32 bit system, libc's
readdir() will return an error because it cannot fit the value into
struct dirent.


As far as I know, there is no way for a FUSE filesystem to tell if the
client process is 64 bit or 32 bit. So effectively, a FUSE filesystem is
limited to using only the lower 32 bits for readdir offsets. Is that
correct?

This would be quite annoying because it means that passthrough
filesystems cannot re-use the underlying filesystems d_off values
(since they will be full 64 bit for a 64 bit FUSE process).


Is there a way for a 64 bit process (in this case the FUSE daemon) to
ask for 32 bit d_off values from getdents64()?


Would it be feasible to extend the FUSE protocol to include information
about the available bits in d_off?


Best,
-Nikolaus

-- 
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«

             reply	other threads:[~2019-11-27  9:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27  9:33 Nikolaus Rath [this message]
2019-11-27 14:30 ` Handling of 32/64 bit off_t by getdents64() Miklos Szeredi
2019-11-27 20:52   ` [fuse-devel] " Nikolaus Rath
2019-11-28  7:42     ` Miklos Szeredi

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=8736e9d5p4.fsf@vostro.rath.org \
    --to=nikolaus@rath.org \
    --cc=fuse-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mszeredi@redhat.com \
    /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.