From 8d039f7bd84ce8cbbbe9ba5677f5a353d6224b66 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Fri, 3 Feb 2017 14:26:15 -0600 Subject: libtar: support backing up and restoring new Android user.* xattr Support for backing up and restoring user.default, user.inode_cache, and user.inode_code_cache xattrs introduced in Android 7.x Change-Id: I6e0aa7fc9cd30ed004ef28ebb58d60a82e518123 --- libtar/append.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'libtar/append.c') diff --git a/libtar/append.c b/libtar/append.c index d8ba3cad5..8896764f2 100644 --- a/libtar/append.c +++ b/libtar/append.c @@ -40,6 +40,7 @@ #ifdef HAVE_EXT4_CRYPT # include "ext4crypt_tar.h" #endif +#include "android_utils.h" struct tar_dev { @@ -172,6 +173,32 @@ tar_append_file(TAR *t, const char *realname, const char *savename) } } + /* get android user.default xattr */ + if (TH_ISDIR(t) && t->options & TAR_STORE_ANDROID_USER_XATTR) + { + if (getxattr(realname, "user.default", NULL, 0) >= 0) + { + t->th_buf.has_user_default = 1; +#if 1 //def DEBUG + printf("storing xattr user.default\n"); +#endif + } + if (getxattr(realname, "user.inode_cache", NULL, 0) >= 0) + { + t->th_buf.has_user_cache = 1; +#if 1 //def DEBUG + printf("storing xattr user.inode_cache\n"); +#endif + } + if (getxattr(realname, "user.inode_code_cache", NULL, 0) >= 0) + { + t->th_buf.has_user_code_cache = 1; +#if 1 //def DEBUG + printf("storing xattr user.inode_code_cache\n"); +#endif + } + } + /* check if it's a hardlink */ #ifdef DEBUG puts("tar_append_file(): checking inode cache for hardlink..."); -- cgit v1.2.3