listxattr broken?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

listxattr broken?

Jack Bates-2
I'm struggling to implement extended attributes

getxattr is working, but listxattr is not

I prepared the attached test case, which I hoped would return "foo" &
"bar" to "getfattr -d" - but instead "getfattr -d" prints nothing -


fis% getfattr -d mnt/foo
fis%


- this is output from test case filesystem -


fis% ./hello -d mnt
unique: 1, opcode: INIT (26), nodeid: 0, insize: 48
INIT: 7.1
   INIT: 7.1
   unique: 1, error: 0 (Success), outsize: 24
unique: 2, opcode: LOOKUP (1), nodeid: 1, insize: 44
LOOKUP /foo
   NODEID: 2
   unique: 2, error: 0 (Success), outsize: 136
unique: 3, opcode: LISTXATTR (23), nodeid: 2, insize: 48
   unique: 3, error: 0 (Success), outsize: 24
unique: 4, opcode: LISTXATTR (23), nodeid: 2, insize: 48
   unique: 4, error: 0 (Success), outsize: 24


I tried on Debian unstable with libfuse2 2.3.0-4 & kernel module in
2.6.13-rc6-mm1

Any ideas?

Thanks!

Jack

hello.c (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: listxattr broken?

Quentin Arce


--- [hidden email] wrote:

> I'm struggling to implement extended attributes
>
> getxattr is working, but listxattr is not
>
> I prepared the attached test case, which I hoped
> would return "foo" &
> "bar" to "getfattr -d" - but instead "getfattr -d"
> prints nothing -
>
>
> fis% getfattr -d mnt/foo
> fis%
>
>
> - this is output from test case filesystem -
>
>
> fis% ./hello -d mnt
> unique: 1, opcode: INIT (26), nodeid: 0, insize: 48
> INIT: 7.1
>    INIT: 7.1
>    unique: 1, error: 0 (Success), outsize: 24
> unique: 2, opcode: LOOKUP (1), nodeid: 1, insize: 44
> LOOKUP /foo
>    NODEID: 2
>    unique: 2, error: 0 (Success), outsize: 136
> unique: 3, opcode: LISTXATTR (23), nodeid: 2,
> insize: 48
>    unique: 3, error: 0 (Success), outsize: 24
> unique: 4, opcode: LISTXATTR (23), nodeid: 2,
> insize: 48
>    unique: 4, error: 0 (Success), outsize: 24
>
>
> I tried on Debian unstable with libfuse2 2.3.0-4 &
> kernel module in
> 2.6.13-rc6-mm1
>
> Any ideas?
>
> Thanks!
>
> Jack> /**
>  * gcc -D_FILE_OFFSET_BITS=64 -c hello.c
>  * gcc -o hello hello.o -lfuse
>  */
>
> #include <fuse.h>
> #include <string.h>
>
> static int hello_getattr(const char *path, struct
> stat *stbuf) {
>     int res = 0;
>
>     memset(stbuf, 0, sizeof(struct stat));
>
>     if (strcmp(path, "/") == 0) {
>         stbuf->st_mode = S_IFDIR | 0755;
>         stbuf->st_nlink = 2;
>     } else {
>         stbuf->st_mode = S_IFREG | 0444;
>         stbuf->st_nlink = 1;
>     }
>
>     return res;
> }
>
> static int hello_getxattr(const char *path, const
> char *name, char *value, size_t size) {
>     strncpy(value, "hello", size);
>     return 5;
> }
>
> static int hello_listxattr(const char *path, char
> *list, size_t size) {



Don't you need to set "size" to be 8. in the memcpy?



>     memcpy(list, "foo\0bar\0", size);
>     return 8;
> }
>
> static struct fuse_operations hello_oper = {
>     .getattr = hello_getattr,
>     .getxattr = hello_getxattr,
>     .listxattr = hello_listxattr
> };
>
> int main(int argc, char *argv[]) {
>     return fuse_main(argc, argv, &hello_oper);
> }



               
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: listxattr broken?

Franco Broi
On Wed, 2005-09-28 at 19:42 -0700, Quentin Arce wrote:

>
>
> Don't you need to set "size" to be 8. in the memcpy?
>


I think the problem is that the size of the list buffer is zero.



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: listxattr broken?

Franco Broi
On Thu, 2005-09-29 at 11:23 +0800, Franco Broi wrote:
> On Wed, 2005-09-28 at 19:42 -0700, Quentin Arce wrote:
>
> >
> >
> > Don't you need to set "size" to be 8. in the memcpy?
> >
>
>
> I think the problem is that the size of the list buffer is zero.


Looks like it's getfattr that's not working.

listx.c

#include <sys/types.h>
#include <attr/xattr.h>

main(int argc, char **argv){

    char list[1024];

    int res = listxattr (*++argv, list, 1024);
    int n=0;


    printf("res %d:", res);

    while((n+=printf(" %s", list+n)) < res);

    printf("\n");

}

# ./listx /hello
res 8: foo bar

#./listx /3d/du.txt
res 8, list realpath


# getfattr /3d/du.txt
getfattr: /3d/du.txt: Numerical result out of range


# getfattr -n realpath /3d/du.txt
getfattr: Removing leading '/' from absolute path names
# file: 3d/du.txt
realpath="/data14/3d/du.txt"




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: listxattr broken?

Franco Broi
It's beginning to make a bit more sense now. listxattr needs to be able
to handle a call with size set to zero, as it says in the man page.

"An empty buffer of size zero can be passed into these calls to return
the current size of the list of extended attribute names, which  can be
used to estimate the size of a buffer which is sufficiently large to
hold the list of names."

But what's not so clear is why getfattr still doesn't work.


static int hello_listxattr(const char *path, char *list, size_t size) {

    printf("Size: %d\n", size);

    if(size == 0) return 8;

    memcpy(list, "foo\0bar\0", 8);
    return 8;
}

# getfattr /hello

# ./hello -f /hello
Size: 0
Size: 256






-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: listxattr broken?

pyro-3
Greetings,

getfattr silently adds a prefix to the query unless you add -m . to the
command line. That might be it.

G'day,
sjames


On Thu, 29 Sep 2005, Franco Broi wrote:

> It's beginning to make a bit more sense now. listxattr needs to be able
> to handle a call with size set to zero, as it says in the man page.
>
> "An empty buffer of size zero can be passed into these calls to return
> the current size of the list of extended attribute names, which  can be
> used to estimate the size of a buffer which is sufficiently large to
> hold the list of names."
>
> But what's not so clear is why getfattr still doesn't work.
>
>
> static int hello_listxattr(const char *path, char *list, size_t size) {
>
>     printf("Size: %d\n", size);
>
>     if(size == 0) return 8;
>
>     memcpy(list, "foo\0bar\0", 8);
>     return 8;
> }
>
> # getfattr /hello
>
> # ./hello -f /hello
> Size: 0
> Size: 256
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> fuse-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/fuse-devel
>

||||| |||| |||||||||||||  |||
by Linux Labs International, Inc.
   Steven James, CTO

55 Marietta Street
Suite 1830
Atlanta, Ga 30303
866 824 9737 support



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: listxattr broken?

Franco Broi
On Thu, 2005-09-29 at 01:10 -0400, Steven James wrote:
> getfattr silently adds a prefix to the query unless you add -m . to the
> command line. That might be it.


Quite right.

# getfattr -m . /hello
getfattr: Removing leading '/' from absolute path names
# file: hello
bar
foo




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: listxattr broken?

Jack Bates-2
On Sep 28, 2005, at 10:32 PM, Franco Broi wrote:

> On Thu, 2005-09-29 at 01:10 -0400, Steven James wrote:
>> getfattr silently adds a prefix to the query unless you add -m . to
>> the
>> command line. That might be it.
>
> Quite right.
>
> # getfattr -m . /hello
> getfattr: Removing leading '/' from absolute path names
> # file: hello
> bar
> foo

Sure enough - that was my problem

Many thanks!

Jack



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel