Xattr on FreeNAS / FreeBSD - Feature request

All your suggestions, requests and ideas for future development
Post Reply
czemo
Posts: 7
Joined: 02 Mar 2018, 00:26

Xattr on FreeNAS / FreeBSD - Feature request

Post by czemo » 03 Mar 2018, 00:44

This is what I found on FreeNAS / FreeBSD about xattr on ZFS.
I wonder if xattr support could be implemented also for this system.

Code: Select all

[[email protected]:/mnt/NAS/plex/test] # setextattr user net.filebot.filename  Arrow-s01e01.mkv Arrow\ -\ 1x01\ -\ Pilot.mkv
        
[[email protected]:/mnt/NAS/plex/test] # lsextattr user Arrow\ -\ 1x01\ -\ Pilot.mkv 
Arrow - 1x01 - Pilot.mkv        net.filebot.filename

[[email protected]:/mnt/NAS/plex/test] # getextattr user net.filebot.filename Arrow\ -\ 1x01\ -\ Pilot.mkv 
Arrow - 1x01 - Pilot.mkv        Arrow-s01e01.mkv

[[email protected]:/mnt/NAS/plex/test] # mount 
NAS/plex on /mnt/NAS/plex (zfs, NFS exported, local, nfsv4acls)
I tested that also under jail:

Code: Select all

[[email protected]:/media/hp-nas/test] # lsextattr user Arrow\ -\ 1x01\ -\ Pilot.mkv          
Arrow - 1x01 - Pilot.mkv        net.filebot.filename
So it IS possible to set and get user level extended attributes on ZFS file system running on FreeBSD.

But as you probably know:

Code: Select all

[[email protected]:/media/hp-nas/test] # filebot -script fn:sysinfo
/opt/filebot:/opt/filebot/lib/amd64
FileBot 4.7.14 (r5241)
JNA Native: 5.2.0
MediaInfo: 17.12
Apache Commons VFS: [zip, rar]
Chromaprint: 1.4.3
Extended Attributes: java.io.IOException: UserDefinedFileAttributeView is not supported
Unicode Filesystem: OK
Script Bundle: 2018-02-04 (r514)
Groovy: 2.4.12
JRE: OpenJDK Runtime Environment 1.8.0_162
JVM: 64-bit OpenJDK 64-Bit Server VM
CPU/MEM: 2 Core / 1 GB Max Memory / 20 MB Used Memory
OS: FreeBSD (amd64)
Package: PORTABLE
uname: FreeBSD plex 11.1-STABLE FreeBSD 11.1-STABLE #0 r321665+de6be8c8d30(freenas/11.1-stable): Tue Feb 20 02:38:09 UTC 2018     [email protected]:/freenas-11-releng/freenas/_BE/objs/freenas-11-releng/freenas/_BE/os/sys/FreeNAS.amd64  amd64
Done ヾ(@⌒ー⌒@)ノ
Tested on FreeBSD 11.1-STABLE

I am almost sure that it's possible to use xattr also with ZFS on FreeBSD with some code changes in FileBot's src.

User avatar
rednoah
The Source
Posts: 14873
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Xattr on FreeNAS / FreeBSD - Feature request

Post by rednoah » 03 Mar 2018, 02:57

FreeBSD is not supported by FileBot in general. Furthermore, Java doesn't support xattr on the underlying platform. However, the same applies to Mac OS X for which I already have a native solution, which might also work on FreeBSD.


Please run this script on your FreeBSD machine and see if it works:

Code: Select all

def p = '/path/to/file.txt' as Path

def xattr = new net.filebot.platform.mac.MacXattrView(p)

println xattr.list()

xattr.write('net.filebot.test', 'Hello World!')

println xattr.read('net.filebot.test')
:idea: /path/to/file.txt needs to be changed to a real file path
:idea: Please read the FAQ and How to Request Help.

czemo
Posts: 7
Joined: 02 Mar 2018, 00:26

Re: Xattr on FreeNAS / FreeBSD - Feature request

Post by czemo » 03 Mar 2018, 03:43

Thank you for reply. Although FreeBSD is not support, FileBot runs there quite well with -no-xattr.

E.g.

Code: Select all

filebot -rename --db TVDB -non-strict -no-xattr tvs
Rename episodes using [TheTVDB]
Auto-detected query: [Arrow]
Fetching episode data for [Arrow]
Fetching episode data for [Sparrow (2016)]
[MOVE] from [/media/hp-nas/test/tvs/Arrow-S01E01.mkv] to [/media/hp-nas/test/tvs/Arrow - 1x01 - Pilot.mkv]
Processed 1 files
But back to the task:

cat test.groovy

Code: Select all

def p = '/media/hp-nas/test/file.txt' as Path

def xattr = new net.filebot.platform.mac.MacXattrView(p)

println xattr.list()

xattr.write('net.filebot.test', 'Hello World!')

println xattr.read('net.filebot.test')
file /media/hp-nas/test/file.txt

Code: Select all

/media/hp-nas/test/file.txt: empty
filebot -script test.groovy

Code: Select all

Error looking up function 'listxattr': Undefined symbol "listxattr"
java.lang.UnsatisfiedLinkError: Error looking up function 'listxattr': Undefined symbol "listxattr"
        at com.sun.jna.Function.<init>(Function.java:245)
        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:566)
        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:542)
        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:528)
        at com.sun.jna.Library$Handler.invoke(Library.java:228)
        at com.sun.jna.platform.mac.$Proxy9.listxattr(Unknown Source)
        at com.sun.jna.platform.mac.XAttrUtil.listXAttr(XAttrUtil.java:37)
        at net.filebot.platform.mac.MacXattrView.list(MacXattrView.java:20)
        at net.filebot.platform.mac.MacXattrView$list.call(Unknown Source)
        at Script1.run(Script1.groovy:5)
        at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:64)
        at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:74)
        at net.filebot.cli.ArgumentProcessor.runScript(ArgumentProcessor.java:127)
        at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:29)
        at net.filebot.Main.main(Main.java:111)

Failure (°_°)
filebot -script fn:sysinfo

Code: Select all

FileBot 4.7.14 (r5241)
JNA Native: 5.2.0
MediaInfo: 17.12
Apache Commons VFS: [zip, rar]
Chromaprint: 1.4.3
Extended Attributes: java.io.IOException: UserDefinedFileAttributeView is not supported
Unicode Filesystem: OK
Script Bundle: 2018-02-04 (r514)
Groovy: 2.4.12
JRE: OpenJDK Runtime Environment 1.8.0_162
JVM: 64-bit OpenJDK 64-Bit Server VM
CPU/MEM: 2 Core / 1 GB Max Memory / 19 MB Used Memory
OS: FreeBSD (amd64)
Package: PORTABLE
uname: FreeBSD plex 11.1-STABLE FreeBSD 11.1-STABLE #0 r321665+de6be8c8d30(freenas/11.1-stable): Tue Feb 20 02:38:09 UTC 2018     [email protected]:/freenas-11-releng/freenas/_BE/objs/freenas-11-releng/freenas/_BE/os/sys/FreeNAS.amd64  amd64
Done ヾ(@⌒ー⌒@)ノ

User avatar
rednoah
The Source
Posts: 14873
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Xattr on FreeNAS / FreeBSD - Feature request

Post by rednoah » 03 Mar 2018, 03:57

Sorry. Bad luck then. The xattr.h native methods are different in Darwin and FreeBSD.

:arrow: I'm unable to spend time on custom code for FreeBSD that doesn't benefit the Windows / Mac Store version of FileBot.
If somebody were to implement, test and contribute xattr.h Java / JNA bindings for FreeBSD to the JNA project, then I could easily add support.

:idea: You could hire me, but my rate is 1000+ USD for a weekend of freelance work. Best to wait until somebody else does it it for free. Maybe. ;)
:idea: Please read the FAQ and How to Request Help.

User avatar
rednoah
The Source
Posts: 14873
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Xattr on FreeNAS / FreeBSD - Feature request

Post by rednoah » 26 Dec 2018, 20:18

czemo wrote:
03 Mar 2018, 00:44
I am almost sure that it's possible to use xattr also with ZFS on FreeBSD with some code changes in FileBot's src.
I've been looking into implementing some basic xattr / extattr support for FreeBSD. Would you like to try a test build and test things a little bit?
:idea: Please read the FAQ and How to Request Help.

czemo
Posts: 7
Joined: 02 Mar 2018, 00:26

Re: Xattr on FreeNAS / FreeBSD - Feature request

Post by czemo » 26 Dec 2018, 20:37

rednoah wrote:
26 Dec 2018, 20:18
Would you like to try a test build and test things a little bit?
Sure! Thanks for your effort.

User avatar
rednoah
The Source
Posts: 14873
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Xattr on FreeNAS / FreeBSD - Feature request

Post by rednoah » 26 Dec 2018, 21:40

:idea: Please read the FAQ and How to Request Help.

czemo
Posts: 7
Joined: 02 Mar 2018, 00:26

Re: Xattr on FreeNAS / FreeBSD - Feature request

Post by czemo » 27 Dec 2018, 00:39

It looks good.

Code: Select all

#lsextattr user Movie\ name\ \(2017\).mkv 
Movie name (2017).mkv        net.filebot.metadata    net.filebot.filename 

User avatar
rednoah
The Source
Posts: 14873
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Xattr on FreeNAS / FreeBSD - Feature request

Post by rednoah » 27 Dec 2018, 05:19

Let's double-check that FileBot can read it's own xattr back. Does this work?

Code: Select all

filebot *.mkv -script "g:println args.metadata"
:idea: Please read the FAQ and How to Request Help.

czemo
Posts: 7
Joined: 02 Mar 2018, 00:26

Re: Xattr on FreeNAS / FreeBSD - Feature request

Post by czemo » 27 Dec 2018, 12:20

Code: Select all

#filebot *.mkv -script "g:println args.metadata"
[Movie name (2017)]
Done ?(?????)?

User avatar
rednoah
The Source
Posts: 14873
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Xattr on FreeNAS / FreeBSD - Feature request

Post by rednoah » 27 Dec 2018, 17:41

Alright. Perfect. Looks good.
:idea: Please read the FAQ and How to Request Help.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests