Quantcast

What is the length of readdir buf?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

What is the length of readdir buf?

Pahome Chen
Hello, all

I check the code this line:
typedef int (*fuse_fill_dir_t) (void *buf, const char *name,const struct stat *stbuf, off_t off);

I wonder that the length of first arguments void *buf ?
Does that define? or just a simply linked list ?

--
Best Regards,
pahome

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the length of readdir buf?

Nikolaus Rath
On Jan 19 2017, Pahome Chen <[hidden email]> wrote:
> Hello, all
>
> I check the code this line:
> typedef int (*fuse_fill_dir_t) (void *buf, const char *name,const struct
> stat *stbuf, off_t off);
>
> I wonder that the length of first arguments void *buf ?
> Does that define? or just a simply linked list ?

buf is declared as a void pointer, but it is actually a more complex
structure that contains, among other things, the length of the
buffer. This is why you must pass in the buf pointer that is passed to
readdir(), rather than some arbitrary buffer.


Best,
-Nikolaus

--
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the length of readdir buf?

Antonio SJ Musumeci
As I recall the behavior is a bit different from libfuse2 to libfuse3. version 2 was rather inefficient in that it had to copy name and stbuf on each call to filler() into it's own buffer and if you set offset to 0 it will simply realloc that buffer as necessary upto 4G if I remember correctly. Then that buffer is freed after building the response.

A better API could be designed which allowed the user to provide the buffers and own their lifecycle and then used iovs as a way to write over the fuse socket so as to limit copying and malloc'ing. Probably would only matter in large sets of data though.

On Fri, Jan 20, 2017 at 1:19 PM, Nikolaus Rath <[hidden email]> wrote:
On Jan 19 2017, Pahome Chen <[hidden email]> wrote:
> Hello, all
>
> I check the code this line:
> typedef int (*fuse_fill_dir_t) (void *buf, const char *name,const struct
> stat *stbuf, off_t off);
>
> I wonder that the length of first arguments void *buf ?
> Does that define? or just a simply linked list ?

buf is declared as a void pointer, but it is actually a more complex
structure that contains, among other things, the length of the
buffer. This is why you must pass in the buf pointer that is passed to
readdir(), rather than some arbitrary buffer.


Best,
-Nikolaus

--
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the length of readdir buf?

Pahome Chen
In reply to this post by Nikolaus Rath
buf is declared as a void pointer, but it is actually a more complex
structure that contains, among other things, the length of the
buffer. This is why you must pass in the buf pointer that is passed to
readdir(), rather than some arbitrary buffer.

Hi, all:

Is there any reference about buf structure I can look up?
because I found nothing info. about the buf structure in fuse.h, fuse_common.h ...etc in libfuse.

thanks for help.
 

2017-01-21 2:19 GMT+08:00 Nikolaus Rath <[hidden email]>:
On Jan 19 2017, Pahome Chen <[hidden email]> wrote:
> Hello, all
>
> I check the code this line:
> typedef int (*fuse_fill_dir_t) (void *buf, const char *name,const struct
> stat *stbuf, off_t off);
>
> I wonder that the length of first arguments void *buf ?
> Does that define? or just a simply linked list ?

buf is declared as a void pointer, but it is actually a more complex
structure that contains, among other things, the length of the
buffer. This is why you must pass in the buf pointer that is passed to
readdir(), rather than some arbitrary buffer.


Best,
-Nikolaus

--
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel



--
Best Regards,
pahome

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the length of readdir buf?

Antonio SJ Musumeci-2
No, it's a opaque data structure. You'll have to look at the filler function.

On Jan 22, 2017 8:35 PM, "Pahome Chen" <[hidden email]> wrote:
buf is declared as a void pointer, but it is actually a more complex
structure that contains, among other things, the length of the
buffer. This is why you must pass in the buf pointer that is passed to
readdir(), rather than some arbitrary buffer.

Hi, all:

Is there any reference about buf structure I can look up?
because I found nothing info. about the buf structure in fuse.h, fuse_common.h ...etc in libfuse.

thanks for help.
 

2017-01-21 2:19 GMT+08:00 Nikolaus Rath <[hidden email]>:
On Jan 19 2017, Pahome Chen <[hidden email]> wrote:
> Hello, all
>
> I check the code this line:
> typedef int (*fuse_fill_dir_t) (void *buf, const char *name,const struct
> stat *stbuf, off_t off);
>
> I wonder that the length of first arguments void *buf ?
> Does that define? or just a simply linked list ?

buf is declared as a void pointer, but it is actually a more complex
structure that contains, among other things, the length of the
buffer. This is why you must pass in the buf pointer that is passed to
readdir(), rather than some arbitrary buffer.


Best,
-Nikolaus

--
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel



--
Best Regards,
pahome

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the length of readdir buf?

Nikolaus Rath
In reply to this post by Pahome Chen
On Jan 23 2017, Pahome Chen <[hidden email]> wrote:

>>
>> buf is declared as a void pointer, but it is actually a more complex
>> structure that contains, among other things, the length of the
>> buffer. This is why you must pass in the buf pointer that is passed to
>> readdir(), rather than some arbitrary buffer.
>
>
> Hi, all:
>
> Is there any reference about *buf structure* I can look up?
> because I found nothing info. about the *buf structure* in fuse.h,
> fuse_common.h ...etc in libfuse.

It is an implementation detail and therefore not included in the public
headers. Your filesystem should never need to know any details.

However, if you are interested out of curiosity, you can look at the
private header: struct fuse_dh in fuse.c:
https://github.com/libfuse/libfuse/blob/master/lib/fuse.c#L177

Best,
-Nikolaus

--
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Loading...