Please forgive my broken English

I try to use setxattr() to sets the value of the extended attribute for some file, the code is like that:

int set_scl(string file_name, char scl)
{
    char scl_data[16];
    scl_data[0] = scl;
    ssize_t size = 1;
    size = setxattr(file_name.c_str(), "user.DosStream.easescl", scl_data, size, 0);
    if (size == -1) 
    {
        perror("set scl:");
        return -1;
    }
    return 0;
}

But once I do this to a file (e.g 1234.xlsx) and then I can't open it however I can still see it. The Excel's error message is:

Can't find \\192.168.2.163\wy\1234.xlsx.

By the way in smb.cnf I have already set vfs objects = acl_xattr streams_xattr like https://www.samba.org/samba/docs/current/man-html/vfs_streams_xattr.8.html

When I use Process Monitor to trace it, I find one event's path is \\192.168.2.163\wy\1234.xlsx:easescl, the operation is 'CreateFile' and the result is 'NAME NOT FOUND'

What should I do to solve this?

1

There are 1 best solutions below

0
On

I find two ways so far,

1)add "streams_xattr:store_stream_type = no" to smb.conf

2)add ":$DATA" to my code like that

size = setxattr(file_name.c_str(), "user.DosStream.easescl:$DATA", scl_data, size, 0);

Both of them are worked,and now i can open the file

However,the value about xattr i set before will be changed once i modify the file and save it, i can't find way to solve it .....