/**
* Convert filesystem metadata to AppleDouble file
**/
-bool ad_unconvert(TALLOC_CTX *mem_ctx,
- struct vfs_handle_struct *handle,
- const char *catia_mappings,
- struct smb_filename *smb_fname,
- bool *converted)
+NTSTATUS ad_unconvert(TALLOC_CTX *mem_ctx,
+ struct vfs_handle_struct *handle,
+ const char *catia_mappings,
+ struct smb_filename *smb_fname,
+ bool *converted)
{
static struct char_mappings **cmaps = NULL;
TALLOC_CTX *frame = talloc_stackframe();
size_t i;
NTSTATUS status;
int ret;
- bool ok;
*converted = false;
mappings = str_list_make_v3_const(
frame, catia_mappings, NULL);
if (mappings == NULL) {
- ok = false;
+ status = NT_STATUS_NO_MEMORY;
goto out;
}
cmaps = string_replace_init_map(mem_ctx, mappings);
status = ad_unconvert_get_streams(
handle, smb_fname, frame, &num_streams, &streams);
if (!NT_STATUS_IS_OK(status)) {
- ok = false;
goto out;
}
}
if (to_convert == 0) {
- ok = true;
+ status = NT_STATUS_OK;
goto out;
}
ret = adouble_path(frame, smb_fname, &adpath);
if (ret != 0) {
- ok = false;
+ status = NT_STATUS_NO_MEMORY;
goto out;
}
state.have_adfile = true;
} else {
if (errno != ENOENT) {
- ok = false;
+ status = map_nt_error_from_unix(errno);
goto out;
}
state.have_adfile = false;
* from an AppleDouble file. Fine, that means there's nothing to
* convert.
*/
- ok = true;
+ status = NT_STATUS_OK;
goto out;
}
ad = ad_init(frame, ADOUBLE_RSRC);
if (ad == NULL) {
- ok = false;
+ status = NT_STATUS_NO_MEMORY;
goto out;
}
status = ad_collect_one_stream(
handle, cmaps, smb_fname, &streams[i], ad, &state);
if (!NT_STATUS_IS_OK(status)) {
- ok = false;
goto out;
}
}
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("Failed to open adfile [%s]\n",
smb_fname_str_dbg(smb_fname));
- ok = false;
goto out;
}
ret = ad_fset(handle, ad, fsp);
if (ret != 0) {
- ok = false;
+ status = NT_STATUS_ACCESS_DENIED; /* probably wrong */
goto out;
}
*converted = true;
- ok = true;
+ status = NT_STATUS_OK;
out:
if (fsp != NULL) {
DBG_ERR("close_file_free() [%s] failed: %s\n",
smb_fname_str_dbg(smb_fname),
nt_errstr(status));
- ok = false;
}
}
TALLOC_FREE(frame);
- return ok;
+ return status;
}
/**
const struct smb_filename *smb_fname,
const char *catia_mappings,
uint32_t flags);
-bool ad_unconvert(TALLOC_CTX *mem_ctx,
- struct vfs_handle_struct *handle,
- const char *catia_mappings,
- struct smb_filename *smb_fname,
- bool *converted);
+NTSTATUS ad_unconvert(TALLOC_CTX *mem_ctx,
+ struct vfs_handle_struct *handle,
+ const char *catia_mappings,
+ struct smb_filename *smb_fname,
+ bool *converted);
struct adouble *ad_init(TALLOC_CTX *ctx, adouble_type_t type);
NTSTATUS adouble_open_from_base_fsp(const struct files_struct *dirfsp,
struct files_struct *base_fsp,
char *p = NULL;
bool converted;
int ret;
- bool ok;
+ NTSTATUS status;
p = strrchr_m(path, '/');
if (p != NULL) {
return false;
}
- ok = ad_unconvert(state.mem_ctx,
- state.conn_tos->conn->vfs_handles,
- macos_string_replace_map,
- smb_fname,
- &converted);
- if (!ok) {
- fprintf(stderr, "Converting failed: %s\n", path);
+ status = ad_unconvert(state.mem_ctx,
+ state.conn_tos->conn->vfs_handles,
+ macos_string_replace_map,
+ smb_fname,
+ &converted);
+ if (!NT_STATUS_IS_OK(status)) {
+ fprintf(stderr,
+ "Converting \"%s\" failed: %s\n",
+ path,
+ nt_errstr(status));
if (state.c->opt_continue_on_error) {
return true;
}