s3-vfstest: Add getxattr
authorVolker Lendecke <vl@samba.org>
Thu, 2 Feb 2012 15:36:18 +0000 (16:36 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 2 Feb 2012 19:35:27 +0000 (20:35 +0100)
source3/torture/cmd_vfs.c

index 667cc1678e00917bb78baed33dad0bfcfdbe9305..c7665656de4f795f1800482602e604b889d339a7 100644 (file)
@@ -1147,6 +1147,41 @@ static NTSTATUS cmd_realpath(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg
        return NT_STATUS_OK;
 }
 
+static NTSTATUS cmd_getxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
+                            int argc, const char **argv)
+{
+       uint8_t *buf;
+       ssize_t ret;
+
+       if (argc != 3) {
+               printf("Usage: getxattr <path> <xattr>\n");
+               return NT_STATUS_OK;
+       }
+
+       buf = NULL;
+
+       ret = SMB_VFS_GETXATTR(vfs->conn, argv[1], argv[2], buf,
+                              talloc_get_size(buf));
+       if (ret == -1) {
+               int err = errno;
+               printf("getxattr returned (%s)\n", strerror(err));
+               return map_nt_error_from_unix(err);
+       }
+       buf = talloc_array(mem_ctx, uint8_t, ret);
+       if (buf == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       ret = SMB_VFS_GETXATTR(vfs->conn, argv[1], argv[2], buf,
+                              talloc_get_size(buf));
+       if (ret == -1) {
+               int err = errno;
+               printf("getxattr returned (%s)\n", strerror(err));
+               return map_nt_error_from_unix(err);
+       }
+       dump_data_file(buf, talloc_get_size(buf), false, stdout);
+       return NT_STATUS_OK;
+}
+
 struct cmd_set vfs_commands[] = {
 
        { "VFS Commands" },
@@ -1187,5 +1222,7 @@ struct cmd_set vfs_commands[] = {
        { "link",   cmd_link,   "VFS link()",    "link <oldpath> <newpath>" },
        { "mknod",   cmd_mknod,   "VFS mknod()",    "mknod <path> <mode> <dev>" },
        { "realpath",   cmd_realpath,   "VFS realpath()",    "realpath <path>" },
+       { "getxattr", cmd_getxattr, "VFS getxattr()",
+         "getxattr <path> <name>" },
        { NULL }
 };