xattr truncated on file move
We've encountered a problem with moving files using gio that an extended attribute is being truncated. For example, using strace on the file move:
strace /local/glib/bin/gio move pr_E1hr_CNRM-CM6-1_amip_r1i1p1f2_gr_200401010030-200812312330.nc /scratch/admin/cjm14/test_cp/
at the end of the ouput:
lstat("/scratch/admin/cjm14/test_cp/pr_E1hr_CNRM-CM6-1_amip_r1i1p1f2_gr_200401010030-200812312330.nc", {st_mode=S_IFREG|0644, st_size=4902096896, ...}) = 0
chmod("/scratch/admin/cjm14/test_cp/pr_E1hr_CNRM-CM6-1_amip_r1i1p1f2_gr_200401010030-200812312330.nc", 0100644) = 0
utimes("/scratch/admin/cjm14/test_cp/pr_E1hr_CNRM-CM6-1_amip_r1i1p1f2_gr_200401010030-200812312330.nc", [{1588341298, 0}, {1587982963, 0}]) = 0
setxattr("/scratch/admin/cjm14/test_cp/pr_E1hr_CNRM-CM6-1_amip_r1i1p1f2_gr_200401010030-200812312330.nc", "lustre.lov", "\320\v\326\v\210\1", 7, 0) = -1 ERANGE (Numerical result out of range)
unlink("/home/c/cjm14/test_copy/CM6amip_cp1/pr_E1hr_CNRM-CM6-1_amip_r1i1p1f2_gr_200401010030-200812312330.nc") = 0
exit_group(0) = ?
+++ exited with 0 +++
The extended attribute lustre.lov is much larger than 7 bytes (392 bytes in this case) however it appears that the gio move is truncating it at the first null character. For reference, moving the same file using GNU mv the equivalent xattr calls:
fgetxattr(3, "lustre.lov", "\320\v\326\v\210\1\0\0\5\0\0\0\0\0\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\0\0\0\0\260\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\20\0\0\0\0\0\20\0\0\0\0\0\0\0\0\10\0\0\0\0\320\0\0\0008\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\20\0\0\0\0\0\0\10\0\0\0\0\377\377\377\377\377\377\377\377\10\1\0\0P\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\320\v\321\v\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\0\0\0\0\320\v\321\v\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\1\0\0\0\202\201\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\320\v\321\v\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0@\0\2\0\0\0\207~\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\253y\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 392) = 392
fsetxattr(4, "lustre.lov", "\320\v\326\v\210\1\0\0\5\0\0\0\0\0\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\0\0\0\0\260\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\20\0\0\0\0\0\20\0\0\0\0\0\0\0\0\10\0\0\0\0\320\0\0\0008\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\20\0\0\0\0\0\0\10\0\0\0\0\377\377\377\377\377\377\377\377\10\1\0\0P\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\320\v\321\v\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\0\0\0\0\320\v\321\v\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\1\0\0\0\202\201\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\320\v\321\v\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0@\0\2\0\0\0\207~\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\253y\10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 392, 0) = 0
The issue is seen on CentOS 7, glib 2.56. I've also tested it with glib 2.64 and see the same problem.
It also seems that gio does not use the /etc/xattr.conf file which defines behavior for copying xattrs for the GNU cp and mv commands. I'm not sure how standard that config file is, but this might be a useful feature.