daemon: xattr: move the listxattrs code in an own function

Move in an own function the code that does the (l)listxattrs allocating
the buffer of the right legth, as it will be useful later.

No functional changes, just code motion.