mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
torture: Introduce error labels for vfstest's cmd_open()
Next patch will have another error exit Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
ac7d0b45fc
commit
b3ab69a435
@ -383,12 +383,11 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
|
|||||||
|
|
||||||
fsp = talloc_zero(vfs, struct files_struct);
|
fsp = talloc_zero(vfs, struct files_struct);
|
||||||
if (fsp == NULL) {
|
if (fsp == NULL) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
goto nomem;
|
||||||
}
|
}
|
||||||
fsp->fh = fd_handle_create(fsp);
|
fsp->fh = fd_handle_create(fsp);
|
||||||
if (fsp->fh == NULL) {
|
if (fsp->fh == NULL) {
|
||||||
TALLOC_FREE(fsp);
|
goto nomem;
|
||||||
return NT_STATUS_NO_MEMORY;
|
|
||||||
}
|
}
|
||||||
fsp->conn = vfs->conn;
|
fsp->conn = vfs->conn;
|
||||||
|
|
||||||
@ -396,15 +395,14 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
|
|||||||
argv[1],
|
argv[1],
|
||||||
lp_posix_pathnames());
|
lp_posix_pathnames());
|
||||||
if (smb_fname == NULL) {
|
if (smb_fname == NULL) {
|
||||||
TALLOC_FREE(fsp);
|
goto nomem;
|
||||||
return NT_STATUS_NO_MEMORY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fsp->fsp_name = smb_fname;
|
fsp->fsp_name = smb_fname;
|
||||||
|
|
||||||
status = vfs_at_fspcwd(fsp, vfs->conn, &fspcwd);
|
status = vfs_at_fspcwd(fsp, vfs->conn, &fspcwd);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
return status;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = SMB_VFS_OPENAT(vfs->conn,
|
fd = SMB_VFS_OPENAT(vfs->conn,
|
||||||
@ -415,9 +413,8 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
|
|||||||
mode);
|
mode);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
printf("open: error=%d (%s)\n", errno, strerror(errno));
|
printf("open: error=%d (%s)\n", errno, strerror(errno));
|
||||||
TALLOC_FREE(fsp);
|
status = map_nt_error_from_unix(errno);
|
||||||
TALLOC_FREE(smb_fname);
|
goto fail;
|
||||||
return NT_STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
}
|
||||||
fsp_set_fd(fsp, fd);
|
fsp_set_fd(fsp, fd);
|
||||||
|
|
||||||
@ -435,9 +432,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
|
|||||||
|
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
fd_close(fsp);
|
fd_close(fsp);
|
||||||
TALLOC_FREE(fsp);
|
goto fail;
|
||||||
TALLOC_FREE(smb_fname);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fsp->file_id = vfs_file_id_from_sbuf(vfs->conn, &smb_fname->st);
|
fsp->file_id = vfs_file_id_from_sbuf(vfs->conn, &smb_fname->st);
|
||||||
@ -454,6 +449,13 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
|
|||||||
vfs->files[fsp_get_pathref_fd(fsp)] = fsp;
|
vfs->files[fsp_get_pathref_fd(fsp)] = fsp;
|
||||||
printf("open: fd=%d\n", fsp_get_pathref_fd(fsp));
|
printf("open: fd=%d\n", fsp_get_pathref_fd(fsp));
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
|
|
||||||
|
nomem:
|
||||||
|
status = NT_STATUS_NO_MEMORY;
|
||||||
|
fail:
|
||||||
|
TALLOC_FREE(smb_fname);
|
||||||
|
TALLOC_FREE(fsp);
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user