Added test for libattr; Renamed macros

Signed-off-by: Alexander Hajnal <trinitydesktop@alephnull.net>
feat/tdeio-xattr-support
Alexander Hajnal 1 year ago
parent a545725e86
commit b77dcf0a14
No known key found for this signature in database
GPG Key ID: 5050665AA3F08058

@ -284,6 +284,15 @@ if( NOT HAVE_SYS_UCRED_H )
endif( ) endif( )
endif( ) endif( )
check_include_file( "sys/xattr.h" HAVE_SYS_XATTR_H ) check_include_file( "sys/xattr.h" HAVE_SYS_XATTR_H )
check_include_file( "attr/libattr.h" HAVE_ATTR_LIBATTR_H)
if ( HAVE_ATTR_LIBATTR_H )
check_library_exists( attr attr_copy_file "" HAVE_ATTR__ATTR_COPY_FILE )
endif( )
if( HAVE_ATTR__ATTR_COPY_FILE )
set( DO_USER_XATTR_COPYING "1" )
message( STATUS "User extended attribute copy support enabled" )
endif( )
check_include_file( "termios.h" HAVE_TERMIOS_H ) check_include_file( "termios.h" HAVE_TERMIOS_H )
check_include_file( "termio.h" HAVE_TERMIO_H ) check_include_file( "termio.h" HAVE_TERMIO_H )
check_include_file( "unistd.h" HAVE_UNISTD_H ) check_include_file( "unistd.h" HAVE_UNISTD_H )

@ -12,11 +12,12 @@ code[4] provided with libattr (examples/copyattr.c).
This code has been in daily use by the author of this patch for just over five This code has been in daily use by the author of this patch for just over five
years without any issues. What's missing though is the addition of tests for years without any issues. What's missing though is the addition of tests for
xattr and libattr support at configuration/compile time. The code I've added xattr and libattr support at configuration/compile time. The code I've added
is enclosed by '#ifdef USE_XATTR' statements so a test should be added that is enclosed by '#ifdef DO_USER_XATTR_COPYING' statements so a test should be
sets this macro[5] if configure-time tests show that xattrs/libattr are working. added that sets this macro[5] if configure-time tests show that xattrs/libattr
I don't know how to go about adding such tests though so I've simply included a are working. I've added a preliminary test to CMakeLists.txt but I'm not sure
'#define USE_XATTR 1' statement to the top of the code. This should obviously it's correct. Alternatively uncomment the '#define DO_USER_XATTR_COPYING 1'
be fixed before general release. statement at the top of the code to force my code to be enabled. Ensuring that
the cmake test working correctly needs to be done before general release.
This code has been tested on select Ubuntu Linux releases (natty, precise, This code has been tested on select Ubuntu Linux releases (natty, precise,
xenial, and jammy) using x86_64 Linux kernels 3.14.1, 4.18.3, and 5.15.0. xenial, and jammy) using x86_64 Linux kernels 3.14.1, 4.18.3, and 5.15.0.
@ -70,8 +71,9 @@ Enjoy!
[4] The code that this patch is based on is licensed GPL v2 (or later). [4] The code that this patch is based on is licensed GPL v2 (or later).
[5] One has to use '#define USE_XATTR 1'; specifying '#define USE_XATTR' [5] One has to use '#define DO_USER_XATTR_COPYING 1'; specifying instead
doesn't enable the code (at least on my system). '#define DO_USER_XATTR_COPYING' doesn't enable the code (at least on my
system).
[6] I'm not sure which non-Linux platforms (if any) libattr runs on. [6] I'm not sure which non-Linux platforms (if any) libattr runs on.

@ -82,15 +82,20 @@ extern "C" {
// Set this macro if libattr is installed and working // This macro is set if user extended attribute support is available.
#define USE_XATTR 1 // Uncomment it here for testing purposes
//#define DO_USER_XATTR_COPYING 1
// To determine which backend is available check for the following macros:
// HAVE_ATTR__ATTR_COPY_FILE -> attr_copy_file via libattr (Linux)
// Extended attribute support (added AKH 2017-11-26, updated AKH 2022-12-16) // Extended attribute support (added AKH 2017-11-26, updated AKH 2022-12-16)
// Based on copyattr.c by Andreas Gruenbacher (included with libattr) // Based on copyattr.c by Andreas Gruenbacher (included with libattr)
// This does NOT also copy Access Control Lists! // This does NOT also copy Access Control Lists!
#ifdef USE_XATTR #ifdef DO_USER_XATTR_COPYING
//#include <stdio.h> // For stderr, (v)fprintf (already included above)
//#include <errno.h> // For errno (already included above) //#include <errno.h> // For errno (already included above)
//#include <stdlib.h> // For free (already included above) //#include <stdlib.h> // For free (already included above)
//#include <string.h> // For errno, strdup, and strcmp (already implictly included above) //#include <string.h> // For errno, strdup, and strcmp (already implictly included above)
@ -2043,7 +2048,7 @@ void FileCopyJob::slotResult( TDEIO::Job *job)
{ {
m_copyJob = 0; m_copyJob = 0;
#ifdef USE_XATTR #ifdef DO_USER_XATTR_COPYING
{ {
// Copy extended attributes (added AKH 2017-11-26) // Copy extended attributes (added AKH 2017-11-26)
attr_copy_file(TQFile::encodeName(m_src.path()), TQFile::encodeName(m_dest.path()), NULL, &ctx); attr_copy_file(TQFile::encodeName(m_src.path()), TQFile::encodeName(m_dest.path()), NULL, &ctx);

Loading…
Cancel
Save