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

index 786eeb8ceda17d95363665774ef6eb68546e07be..9e1c62db101da9cda1e14944b48c495c6c9f5d8e 100644 (file)
@@ -1228,6 +1228,31 @@ static NTSTATUS cmd_listxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
        return NT_STATUS_OK;
 }
 
+static NTSTATUS cmd_setxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
+                            int argc, const char **argv)
+{
+       ssize_t ret;
+       int flags = 0;
+
+       if ((argc < 4) || (argc > 5)) {
+               printf("Usage: setxattr <path> <xattr> <value> [flags]\n");
+               return NT_STATUS_OK;
+       }
+
+       if (argc == 5) {
+               flags = atoi(argv[4]);
+       }
+
+       ret = SMB_VFS_SETXATTR(vfs->conn, argv[1], argv[2],
+                              argv[3], strlen(argv[3]), flags);
+       if (ret == -1) {
+               int err = errno;
+               printf("setxattr returned (%s)\n", strerror(err));
+               return map_nt_error_from_unix(err);
+       }
+       return NT_STATUS_OK;
+}
+
 struct cmd_set vfs_commands[] = {
 
        { "VFS Commands" },
@@ -1272,5 +1297,7 @@ struct cmd_set vfs_commands[] = {
          "getxattr <path> <name>" },
        { "listxattr", cmd_listxattr, "VFS listxattr()",
          "listxattr <path>" },
+       { "setxattr", cmd_setxattr, "VFS setxattr()",
+         "setxattr <path> <name> <value> [<flags>]" },
        { NULL }
 };