Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Feb 2021 14:05:31 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 253411] FUSE driver doesn't populate dirent->d_off
Message-ID:  <bug-253411-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D253411

            Bug ID: 253411
           Summary: FUSE driver doesn't populate dirent->d_off
           Product: Base System
           Version: 12.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: jmillikin@gmail.com

Documentation for functions such as getdirentries(2) or getdents(2) describ=
e a
`d_off' field of `struct dirent' as a cookie that can be passed to lseek(2)=
 to
resume a directory seek at a given position. This field is not set for dire=
nts
read from a FUSE filesystem.

I believe this may be caused by a missing field assignment in
`fuse_internal_readdir_processdata()'.

Below is a simple test driver that will print out dirent fields for a provi=
ded
directory. Run it on a UFS volume and a fusefs volume to see different `d_o=
ff'
behavior.

------------

#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>

int main(int argc, char **argv) {
  if (argc !=3D 2) {
    fprintf(stderr, "usage: %s DIRPATH\n", argv[0]);
    return 1;
  }
  DIR *dir_p =3D opendir(argv[1]);
  int dir_fd =3D dirfd(dir_p);
  char buf[4096];
  ssize_t rc =3D getdents(dir_fd, buf, 4096);

  ssize_t offset =3D 0;
  int ii =3D 0;
  while (offset < rc) {
    struct dirent *dent =3D (struct dirent*)(buf + offset);
    printf("dents[%d] =3D {\n", ii);
    printf("  .d_fileno =3D %lu,\n", dent->d_fileno);
    printf("  .d_off =3D %ld,\n", dent->d_off);
    printf("  .d_name =3D \"%s\",\n", dent->d_name);
    printf("}\n");
    offset +=3D dent->d_reclen;
    ii +=3D 1;
  }

  return 0;
}

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-253411-227>