1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Find out whether filesystem supports extended attributes

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024 às 14:12.

  1. Stack

    Stack Membro Participativo

    I have python program that calls another (external) program:

    cmd = [ "unsquashfs", "-n", "-d", dirname, filename ]
    subprocess.check_call( cmd )


    It worked so far. But now I started running this program in /tmp with tmpfs filesystem, which doesn't support xattrs and program subprocess fails with:

    write_xattr: failed to write xattr user.random-seed-creditable for file some/file/somewhere because extended attributes are not supported by the destination filesystem
    Ignoring xattrs in filesystem
    To avoid this error message, specify -no-xattrs


    It very kindly informed me I need to add another param, great. But the program belongs to different team, whole company uses it so I would like to minimize my change and add the param only when needed (when xattrs are not supported) - for all I know somebody somewhere depends on xattrs being set in normal case. So, how do I implement the following?:

    if not filesystemSupportsXattrs(dirname):
    cmd += ['-no-xattrs']

    Continue reading...

Compartilhe esta Página