From 7df04d09085d3fb05e0a4d7ede654dac8466c770 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 29 Jan 2025 15:11:16 +0100 Subject: [PATCH] mdssvc: support a few more attributes 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 Reviewed-by: Stefan Metzmacher (cherry picked from commit 0ba1a8d77694182058d1c01b54a8759bdf0e28a6) --- source3/rpc_server/mdssvc/mdssvc.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c index 23a30884b696..b007f9cad656 100644 --- a/source3/rpc_server/mdssvc/mdssvc.c +++ b/source3/rpc_server/mdssvc/mdssvc.c @@ -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, -- 2.47.0