diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index 620320f..0de76ef 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -229,11 +229,21 @@ get_selinux_context (const char            *path,
 #ifdef HAVE_XATTR_NOFOLLOW
 #define g_fgetxattr(fd,name,value,size)  fgetxattr(fd,name,value,size,0,0)
 #define g_flistxattr(fd,name,size)       flistxattr(fd,name,size,0)
-#define g_setxattr(path,name,value,size) setxattr(path,name,value,size,0,0)
+static inline int g_setxattr(const char *path, const char *name, const void *value, size_t size) {
+  if ((value == NULL) && (size == 0))
+    return removexattr(path, name); 
+  else
+    return setxattr(path,name,value,size,0,0); 
+}
 #else
 #define g_fgetxattr     fgetxattr
 #define g_flistxattr    flistxattr
-#define g_setxattr(path,name,value,size) setxattr(path,name,value,size,0)
+static inline int g_setxattr(const char *path, const char *name, const void *value, size_t size) {
+  if ((value == NULL) && (size == 0))
+    return removexattr(path, name); 
+  else
+    return setxattr(path,name,value,size,0);
+}
 #endif
 
 static ssize_t
@@ -722,10 +732,10 @@ set_xattr (char                       *filename,
       return FALSE;
     }
 
-  if (attr_value->type != G_FILE_ATTRIBUTE_TYPE_STRING)
+  if ((attr_value->type != G_FILE_ATTRIBUTE_TYPE_STRING) && (attr_value->type != G_FILE_ATTRIBUTE_TYPE_INVALID))
     {
       g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
-                           _("Invalid attribute type (string expected)"));
+                           _("Invalid attribute type (string or invalid expected)"));
       return FALSE;
     }
 
@@ -749,7 +759,15 @@ set_xattr (char                       *filename,
     }
   
   attribute = hex_unescape_string (escaped_attribute, NULL, &free_attribute);
-  value = hex_unescape_string (attr_value->u.string, &val_len, &free_value);
+  if (attr_value->type == G_FILE_ATTRIBUTE_TYPE_STRING)
+    {
+      value = hex_unescape_string (attr_value->u.string, &val_len, &free_value);
+    }
+  else 
+    {
+      value = NULL;
+      val_len = 0;
+    }
 
   if (is_user)
     a = g_strconcat ("user.", attribute, NULL);
