]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Convert ad_unconvert() to NTSTATUS
authorVolker Lendecke <vl@samba.org>
Wed, 19 Mar 2025 16:29:40 +0000 (17:29 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 27 Mar 2025 13:13:31 +0000 (13:13 +0000)
Drop error information later

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/lib/adouble.c
source3/lib/adouble.h
source3/utils/net_vfs.c

index 61e55e241d65031f1365911ec83378e41a540f8b..fe1be8e6f36d585251f9cc5388d305660d4b7a37 100644 (file)
@@ -1975,11 +1975,11 @@ out:
 /**
  * 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();
@@ -1994,7 +1994,6 @@ bool ad_unconvert(TALLOC_CTX *mem_ctx,
        size_t i;
        NTSTATUS status;
        int ret;
-       bool ok;
 
        *converted = false;
 
@@ -2004,7 +2003,7 @@ bool ad_unconvert(TALLOC_CTX *mem_ctx,
                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);
@@ -2014,7 +2013,6 @@ bool ad_unconvert(TALLOC_CTX *mem_ctx,
        status = ad_unconvert_get_streams(
                handle, smb_fname, frame, &num_streams, &streams);
        if (!NT_STATUS_IS_OK(status)) {
-               ok = false;
                goto out;
        }
 
@@ -2029,7 +2027,7 @@ bool ad_unconvert(TALLOC_CTX *mem_ctx,
        }
 
        if (to_convert == 0) {
-               ok = true;
+               status = NT_STATUS_OK;
                goto out;
        }
 
@@ -2039,7 +2037,7 @@ bool ad_unconvert(TALLOC_CTX *mem_ctx,
 
        ret = adouble_path(frame, smb_fname, &adpath);
        if (ret != 0) {
-               ok = false;
+               status = NT_STATUS_NO_MEMORY;
                goto out;
        }
 
@@ -2048,7 +2046,7 @@ bool ad_unconvert(TALLOC_CTX *mem_ctx,
                state.have_adfile = true;
        } else {
                if (errno != ENOENT) {
-                       ok = false;
+                       status = map_nt_error_from_unix(errno);
                        goto out;
                }
                state.have_adfile = false;
@@ -2060,13 +2058,13 @@ bool ad_unconvert(TALLOC_CTX *mem_ctx,
                 * 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;
        }
 
@@ -2074,7 +2072,6 @@ bool ad_unconvert(TALLOC_CTX *mem_ctx,
                status = ad_collect_one_stream(
                        handle, cmaps, smb_fname, &streams[i], ad, &state);
                if (!NT_STATUS_IS_OK(status)) {
-                       ok = false;
                        goto out;
                }
        }
@@ -2083,18 +2080,17 @@ bool ad_unconvert(TALLOC_CTX *mem_ctx,
        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) {
@@ -2103,11 +2099,10 @@ out:
                        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;
 }
 
 /**
index d2c729305f9c28b4a600352db6433c502635aa73..3caac47185d4e8e49b581dca324b6f9753979df3 100644 (file)
@@ -159,11 +159,11 @@ int ad_convert(struct vfs_handle_struct *handle,
                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,
index a8d2a9f72d5f201d254a1ffb110f469052c306b8..da8a7dccce7e5d11a6a4c7d822cb6f636598be89 100644 (file)
@@ -317,7 +317,7 @@ static bool do_unfruit(const char *path)
        char *p = NULL;
        bool converted;
        int ret;
-       bool ok;
+       NTSTATUS status;
 
        p = strrchr_m(path, '/');
        if (p != NULL) {
@@ -345,13 +345,16 @@ static bool do_unfruit(const char *path)
                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;
                }