]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
mdssvc: support a few more attributes
authorRalph Boehme <slow@samba.org>
Wed, 29 Jan 2025 14:11:16 +0000 (15:11 +0100)
committerJule Anger <janger@samba.org>
Mon, 17 Feb 2025 17:28:37 +0000 (17:28 +0000)
This adds support for the following Spotlight Metadata Attributes:

  _kMDItemFileName (another alias for kMDItemFSName and kMDItemDisplayName)
  kMDItemLastUsedDate
  kMDItemContentCreationDate
  kMDItemLogicalSize (another alias for kMDItemFSSize)

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15796

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 0ba1a8d77694182058d1c01b54a8759bdf0e28a6)

Autobuild-User(v4-20-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-20-test): Mon Feb 17 17:28:37 UTC 2025 on atb-devel-224

source3/rpc_server/mdssvc/mdssvc.c

index 23a30884b696d03848bcad1df61928b290ec6dc2..b007f9cad656d78c24c06fe1309472724bffe07b 100644 (file)
@@ -157,7 +157,8 @@ static bool add_filemeta(struct mds_ctx *mds_ctx,
                        return false;
                }
                if (strcmp(attribute, "kMDItemDisplayName") == 0
-                   || strcmp(attribute, "kMDItemFSName") == 0) {
+                   || strcmp(attribute, "kMDItemFSName") == 0
+                   || strcmp(attribute, "_kMDItemFileName") == 0) {
                        p = strrchr(nfd_path, '/');
                        if (p) {
                                result = dalloc_stradd(meta, p + 1);
@@ -170,7 +171,9 @@ static bool add_filemeta(struct mds_ctx *mds_ctx,
                        if (result != 0) {
                                return false;
                        }
-               } else if (strcmp(attribute, "kMDItemFSSize") == 0) {
+               } else if (strcmp(attribute, "kMDItemFSSize") == 0
+                       || strcmp(attribute, "kMDItemLogicalSize") == 0)
+               {
                        uint64var = sp->st_ex_size;
                        result = dalloc_add_copy(meta, &uint64var, uint64_t);
                        if (result != 0) {
@@ -196,6 +199,18 @@ static bool add_filemeta(struct mds_ctx *mds_ctx,
                        if (result != 0) {
                                return false;
                        }
+               } else if (strcmp(attribute, "kMDItemLastUsedDate") == 0) {
+                       sl_time = convert_timespec_to_timeval(sp->st_ex_atime);
+                       result = dalloc_add_copy(meta, &sl_time, sl_time_t);
+                       if (result != 0) {
+                               return false;
+                       }
+               } else if (strcmp(attribute, "kMDItemContentCreationDate") == 0) {
+                       sl_time = convert_timespec_to_timeval(sp->st_ex_btime);
+                       result = dalloc_add_copy(meta, &sl_time, sl_time_t);
+                       if (result != 0) {
+                               return false;
+                       }
                } else {
                        result = dalloc_add_copy(meta, &nil, sl_nil_t);
                        if (result != 0) {
@@ -579,7 +594,9 @@ bool mds_add_result(struct sl_query *slq, const char *path)
                return true;
        }
 
-       sb = smb_fname->st;
+       fdos_mode(smb_fname->fsp);
+
+       sb = smb_fname->fsp->fsp_name->st;
 
        status = smbd_check_access_rights_fsp(slq->mds_ctx->conn->cwd_fsp,
                                              smb_fname->fsp,