mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-30 03:47:02 -05:00
additional readdir refactor cleanup
Differences between readdir and getdents is minimal at best. Leaving code for now to allow for possible expansion later.
This commit is contained in:
parent
4160a8e2f8
commit
dbdd3e22fc
28 changed files with 453 additions and 177 deletions
|
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
#include "fuse_dirent.h"
|
||||
#include "fuse_direntplus.h"
|
||||
#include "fuse_entry.h"
|
||||
#include "linux_dirent64.h"
|
||||
#include "linux_dirent.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <stdint.h>
|
||||
|
|
@ -63,14 +63,14 @@ int fuse_dirents_add_plus(fuse_dirents_t *d,
|
|||
const uint64_t namelen,
|
||||
const fuse_entry_t *entry,
|
||||
const struct stat *st);
|
||||
int fuse_dirents_add_linux(fuse_dirents_t *d,
|
||||
const struct linux_dirent64 *de,
|
||||
const uint64_t namelen);
|
||||
int fuse_dirents_add_linux_plus(fuse_dirents_t *d,
|
||||
const struct linux_dirent64 *de,
|
||||
const uint64_t namelen,
|
||||
const fuse_entry_t *entry,
|
||||
const struct stat *st);
|
||||
int fuse_dirents_add_linux(fuse_dirents_t *d,
|
||||
const struct linux_dirent *de,
|
||||
const uint64_t namelen);
|
||||
int fuse_dirents_add_linux_plus(fuse_dirents_t *d,
|
||||
const struct linux_dirent *de,
|
||||
const uint64_t namelen,
|
||||
const fuse_entry_t *entry,
|
||||
const struct stat *st);
|
||||
|
||||
void *fuse_dirents_find(fuse_dirents_t *d,
|
||||
const uint64_t ino);
|
||||
|
|
|
|||
9
libfuse/include/linux_dirent.h
Normal file
9
libfuse/include/linux_dirent.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
struct linux_dirent
|
||||
{
|
||||
unsigned long ino;
|
||||
unsigned long off;
|
||||
unsigned short reclen;
|
||||
char name[];
|
||||
};
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct linux_dirent64
|
||||
{
|
||||
uint64_t d_ino;
|
||||
int64_t d_off;
|
||||
uint16_t d_reclen;
|
||||
uint8_t d_type;
|
||||
char d_name[];
|
||||
};
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
#include "fuse_direntplus.h"
|
||||
#include "fuse_dirents.h"
|
||||
#include "fuse_entry.h"
|
||||
#include "linux_dirent64.h"
|
||||
#include "linux_dirent.h"
|
||||
#include "stat_utils.h"
|
||||
|
||||
#include <dirent.h>
|
||||
|
|
@ -16,7 +16,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DEFAULT_SIZE (1024 * 16)
|
||||
/* 32KB - same as glibc getdents buffer size */
|
||||
#define DEFAULT_SIZE (1024 * 32)
|
||||
|
||||
static
|
||||
uint64_t
|
||||
|
|
@ -308,9 +309,9 @@ fuse_dirents_add_plus(fuse_dirents_t *d_,
|
|||
}
|
||||
|
||||
int
|
||||
fuse_dirents_add_linux(fuse_dirents_t *d_,
|
||||
const struct linux_dirent64 *dirent_,
|
||||
const uint64_t namelen_)
|
||||
fuse_dirents_add_linux(fuse_dirents_t *d_,
|
||||
const struct linux_dirent *dirent_,
|
||||
const uint64_t namelen_)
|
||||
{
|
||||
uint64_t size;
|
||||
fuse_dirent_t *d;
|
||||
|
|
@ -332,21 +333,21 @@ fuse_dirents_add_linux(fuse_dirents_t *d_,
|
|||
if(d == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
d->ino = dirent_->d_ino;
|
||||
d->ino = dirent_->ino;
|
||||
d->off = d_->data_len;
|
||||
d->namelen = namelen_;
|
||||
d->type = dirent_->d_type;
|
||||
memcpy(d->name,dirent_->d_name,namelen_);
|
||||
d->type = *((char*)dirent_ + dirent_->reclen - 1);
|
||||
memcpy(d->name,dirent_->name,namelen_);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
fuse_dirents_add_linux_plus(fuse_dirents_t *d_,
|
||||
const struct linux_dirent64 *dirent_,
|
||||
const uint64_t namelen_,
|
||||
const fuse_entry_t *entry_,
|
||||
const struct stat *st_)
|
||||
fuse_dirents_add_linux_plus(fuse_dirents_t *d_,
|
||||
const struct linux_dirent *dirent_,
|
||||
const uint64_t namelen_,
|
||||
const fuse_entry_t *entry_,
|
||||
const struct stat *st_)
|
||||
{
|
||||
uint64_t size;
|
||||
fuse_direntplus_t *d;
|
||||
|
|
@ -368,11 +369,11 @@ fuse_dirents_add_linux_plus(fuse_dirents_t *d_,
|
|||
if(d == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
d->dirent.ino = dirent_->d_ino;
|
||||
d->dirent.ino = dirent_->ino;
|
||||
d->dirent.off = d_->data_len;
|
||||
d->dirent.namelen = namelen_;
|
||||
d->dirent.type = dirent_->d_type;
|
||||
memcpy(d->dirent.name,dirent_->d_name,namelen_);
|
||||
d->dirent.type = *((char*)dirent_ + dirent_->reclen - 1);
|
||||
memcpy(d->dirent.name,dirent_->name,namelen_);
|
||||
|
||||
d->entry = *entry_;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue