- From 7334641ac3cf3a046b96804a0080614a6a4c36b1 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 13 Apr 2024 11:30:41 +0200
- Subject: [PATCH 1/3] winfsinfo: Add subcommands and switch to ksh93 compound
- variable output
- Add subcommands ("getvolumeinfo", "filebasicinfo", "filestandardinfo")
- and switch to ksh93 compound variable output (so ksh93 can read
- the info via ksh93 -c 'compound cpy; read -C cpv ; ...'
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- tests/winfsinfo1/winfsinfo.c | 255 +++++++++++++++++++++++++++++------
- 1 file changed, 213 insertions(+), 42 deletions(-)
- diff --git a/tests/winfsinfo1/winfsinfo.c b/tests/winfsinfo1/winfsinfo.c
- index 361e2d2..3c5a2bb 100644
- --- a/tests/winfsinfo1/winfsinfo.c
- +++ b/tests/winfsinfo1/winfsinfo.c
- @@ -1,7 +1,7 @@
- /*
- * MIT License
- *
- - * Copyright (c) 2023 Roland Mainz <roland.mainz@nrubsig.org>
- + * Copyright (c) 2023-2024 Roland Mainz <roland.mainz@nrubsig.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- @@ -23,7 +23,8 @@
- */
- /*
- - * winfsinfo1.c - print Windows filesystem info
- + * winfsinfo1.c - print Windows filesystem info in ksh93 compound
- + * variable format (suiteable for ksh93 $ read -C varnname #)
- *
- * Written by Roland Mainz <roland.mainz@nrubsig.org>
- */
- @@ -37,9 +38,10 @@
- #include <stdbool.h>
- static
- -bool print_volume_info(const char *progname, const char *filename)
- +bool getvolumeinfo(const char *progname, const char *filename)
- {
- - bool ok = false;
- + int res = EXIT_FAILURE;
- + bool ok;
- HANDLE fileHandle = CreateFileA(filename,
- GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
- @@ -50,11 +52,9 @@ bool print_volume_info(const char *progname, const char *filename)
- progname,
- filename,
- GetLastError());
- - return false;
- + return EXIT_FAILURE;
- }
- - (void)printf("filename='%s'\n", filename);
- -
- DWORD volumeFlags = 0;
- ok = GetVolumeInformationByHandleW(fileHandle, NULL, 0,
- NULL, NULL, &volumeFlags, NULL, 0);
- @@ -64,68 +64,239 @@ bool print_volume_info(const char *progname, const char *filename)
- "error. GetLastError()==%d.\n",
- progname,
- GetLastError());
- - ok = false;
- + res = EXIT_FAILURE;
- goto done;
- }
- -#define TESTFSATTR(s) \
- + (void)printf("(\n");
- + (void)printf("\tfilename='%s'\n", filename);
- + (void)printf("\ttypeset -a volumeflags=(\n");
- +
- +#define TESTVOLFLAG(s) \
- if (volumeFlags & (s)) { \
- - (void)puts("volumeflag="#s); \
- + (void)puts("\t\t"#s); \
- volumeFlags &= ~(s); \
- }
- - TESTFSATTR(FILE_SUPPORTS_USN_JOURNAL);
- - TESTFSATTR(FILE_SUPPORTS_OPEN_BY_FILE_ID);
- - TESTFSATTR(FILE_SUPPORTS_EXTENDED_ATTRIBUTES);
- - TESTFSATTR(FILE_SUPPORTS_HARD_LINKS);
- - TESTFSATTR(FILE_SUPPORTS_TRANSACTIONS);
- - TESTFSATTR(FILE_SEQUENTIAL_WRITE_ONCE);
- - TESTFSATTR(FILE_READ_ONLY_VOLUME);
- - TESTFSATTR(FILE_NAMED_STREAMS);
- - TESTFSATTR(FILE_SUPPORTS_ENCRYPTION);
- - TESTFSATTR(FILE_SUPPORTS_OBJECT_IDS);
- - TESTFSATTR(FILE_VOLUME_IS_COMPRESSED);
- - TESTFSATTR(FILE_SUPPORTS_REMOTE_STORAGE);
- - TESTFSATTR(FILE_RETURNS_CLEANUP_RESULT_INFO);
- - TESTFSATTR(FILE_SUPPORTS_POSIX_UNLINK_RENAME);
- - TESTFSATTR(FILE_SUPPORTS_REPARSE_POINTS);
- - TESTFSATTR(FILE_SUPPORTS_SPARSE_FILES);
- - TESTFSATTR(FILE_VOLUME_QUOTAS);
- - TESTFSATTR(FILE_FILE_COMPRESSION);
- - TESTFSATTR(FILE_PERSISTENT_ACLS);
- - TESTFSATTR(FILE_UNICODE_ON_DISK);
- - TESTFSATTR(FILE_CASE_PRESERVED_NAMES);
- - TESTFSATTR(FILE_CASE_SENSITIVE_SEARCH);
- - TESTFSATTR(FILE_SUPPORTS_INTEGRITY_STREAMS);
- + TESTVOLFLAG(FILE_SUPPORTS_USN_JOURNAL);
- + TESTVOLFLAG(FILE_SUPPORTS_OPEN_BY_FILE_ID);
- + TESTVOLFLAG(FILE_SUPPORTS_EXTENDED_ATTRIBUTES);
- + TESTVOLFLAG(FILE_SUPPORTS_HARD_LINKS);
- + TESTVOLFLAG(FILE_SUPPORTS_TRANSACTIONS);
- + TESTVOLFLAG(FILE_SEQUENTIAL_WRITE_ONCE);
- + TESTVOLFLAG(FILE_READ_ONLY_VOLUME);
- + TESTVOLFLAG(FILE_NAMED_STREAMS);
- + TESTVOLFLAG(FILE_SUPPORTS_ENCRYPTION);
- + TESTVOLFLAG(FILE_SUPPORTS_OBJECT_IDS);
- + TESTVOLFLAG(FILE_VOLUME_IS_COMPRESSED);
- + TESTVOLFLAG(FILE_SUPPORTS_REMOTE_STORAGE);
- + TESTVOLFLAG(FILE_RETURNS_CLEANUP_RESULT_INFO);
- + TESTVOLFLAG(FILE_SUPPORTS_POSIX_UNLINK_RENAME);
- + TESTVOLFLAG(FILE_SUPPORTS_REPARSE_POINTS);
- + TESTVOLFLAG(FILE_SUPPORTS_SPARSE_FILES);
- + TESTVOLFLAG(FILE_VOLUME_QUOTAS);
- + TESTVOLFLAG(FILE_FILE_COMPRESSION);
- + TESTVOLFLAG(FILE_PERSISTENT_ACLS);
- + TESTVOLFLAG(FILE_UNICODE_ON_DISK);
- + TESTVOLFLAG(FILE_CASE_PRESERVED_NAMES);
- + TESTVOLFLAG(FILE_CASE_SENSITIVE_SEARCH);
- + TESTVOLFLAG(FILE_SUPPORTS_INTEGRITY_STREAMS);
- #ifdef FILE_SUPPORTS_BLOCK_REFCOUNTING
- - TESTFSATTR(FILE_SUPPORTS_BLOCK_REFCOUNTING);
- + TESTVOLFLAG(FILE_SUPPORTS_BLOCK_REFCOUNTING);
- #endif
- #ifdef FILE_SUPPORTS_SPARSE_VDL
- - TESTFSATTR(FILE_SUPPORTS_SPARSE_VDL);
- + TESTVOLFLAG(FILE_SUPPORTS_SPARSE_VDL);
- #endif
- #ifdef FILE_DAX_VOLUME
- - TESTFSATTR(FILE_DAX_VOLUME);
- + TESTVOLFLAG(FILE_DAX_VOLUME);
- #endif
- #ifdef FILE_SUPPORTS_GHOSTING
- - TESTFSATTR(FILE_SUPPORTS_GHOSTING);
- + TESTVOLFLAG(FILE_SUPPORTS_GHOSTING);
- #endif
- + (void)printf("\t)\n");
- +
- /*
- - * print any leftover flags not covered by |TESTFSATTR(FILE_*)|
- + * print any leftover flags not covered by |TESTVOLFLAG(FILE_*)|
- * above
- */
- if (volumeFlags) {
- - (void)printf("attr=0x%lx\n", (long)volumeFlags);
- + (void)printf("\tattr=0x%lx\n", (long)volumeFlags);
- + }
- + (void)printf(")\n");
- + res = EXIT_SUCCESS;
- +
- +done:
- + CloseHandle(fileHandle);
- + return res;
- +}
- +
- +
- +static
- +bool get_file_basic_info(const char *progname, const char *filename)
- +{
- + int res = EXIT_FAILURE;
- + bool ok;
- + FILE_BASIC_INFO finfo = { 0 };
- +
- + HANDLE fileHandle = CreateFileA(filename,
- + GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
- + FILE_FLAG_BACKUP_SEMANTICS, NULL);
- + if (fileHandle == INVALID_HANDLE_VALUE) {
- + (void)fprintf(stderr,
- + "%s: Error opening file '%s'. Last error was %d.\n",
- + progname,
- + filename,
- + GetLastError());
- + return EXIT_FAILURE;
- }
- - ok = true;
- +
- + ok = GetFileInformationByHandleEx(fileHandle, FileBasicInfo, &finfo,
- + sizeof(finfo));
- +
- + if (!ok) {
- + (void)fprintf(stderr, "%s: GetFileInformationByHandleEx() "
- + "error. GetLastError()==%d.\n",
- + progname,
- + GetLastError());
- + res = EXIT_FAILURE;
- + goto done;
- + }
- +
- + (void)printf("(\n");
- + (void)printf("\tfilename='%s'\n", filename);
- +
- + (void)printf("\tCreationTime=%lld\n", (long long)finfo.CreationTime.QuadPart);
- + (void)printf("\tLastAccessTime=%lld\n", (long long)finfo.LastAccessTime.QuadPart);
- + (void)printf("\tLastWriteTime=%lld\n", (long long)finfo.LastWriteTime.QuadPart);
- + (void)printf("\tChangeTime=%lld\n", (long long)finfo.ChangeTime.QuadPart);
- + DWORD fattr = finfo.FileAttributes;
- +
- + (void)printf("\ttypeset -a FileAttributes=(\n");
- +
- +#define TESTFBIA(s) \
- + if (fattr & (s)) { \
- + (void)puts("\t\t"#s); \
- + fattr &= ~(s); \
- + }
- + TESTFBIA(FILE_ATTRIBUTE_READONLY);
- + TESTFBIA(FILE_ATTRIBUTE_HIDDEN);
- + TESTFBIA(FILE_ATTRIBUTE_SYSTEM);
- + TESTFBIA(FILE_ATTRIBUTE_DIRECTORY);
- + TESTFBIA(FILE_ATTRIBUTE_ARCHIVE);
- + TESTFBIA(FILE_ATTRIBUTE_DEVICE);
- + TESTFBIA(FILE_ATTRIBUTE_NORMAL);
- + TESTFBIA(FILE_ATTRIBUTE_TEMPORARY);
- + TESTFBIA(FILE_ATTRIBUTE_SPARSE_FILE);
- + TESTFBIA(FILE_ATTRIBUTE_REPARSE_POINT);
- + TESTFBIA(FILE_ATTRIBUTE_COMPRESSED);
- + TESTFBIA(FILE_ATTRIBUTE_OFFLINE);
- + TESTFBIA(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
- + TESTFBIA(FILE_ATTRIBUTE_ENCRYPTED);
- + TESTFBIA(FILE_ATTRIBUTE_INTEGRITY_STREAM);
- + TESTFBIA(FILE_ATTRIBUTE_VIRTUAL);
- + TESTFBIA(FILE_ATTRIBUTE_NO_SCRUB_DATA);
- + TESTFBIA(FILE_ATTRIBUTE_EA);
- + TESTFBIA(FILE_ATTRIBUTE_PINNED);
- + TESTFBIA(FILE_ATTRIBUTE_UNPINNED);
- + TESTFBIA(FILE_ATTRIBUTE_RECALL_ON_OPEN);
- + TESTFBIA(FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS);
- +
- + (void)printf("\t)\n");
- +
- + /*
- + * print any leftover flags not covered by |TESTFBIA(FILE_*)|
- + * above
- + */
- + if (fattr) {
- + (void)printf("\tfattr=0x%lx\n", (long)fattr);
- + }
- + (void)printf(")\n");
- + res = EXIT_SUCCESS;
- done:
- CloseHandle(fileHandle);
- - return ok;
- + return res;
- +}
- +
- +
- +static
- +bool get_file_standard_info(const char *progname, const char *filename)
- +{
- + int res = EXIT_FAILURE;
- + bool ok;
- + FILE_STANDARD_INFO finfo = { 0 };
- +
- + HANDLE fileHandle = CreateFileA(filename,
- + GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
- + FILE_FLAG_BACKUP_SEMANTICS, NULL);
- + if (fileHandle == INVALID_HANDLE_VALUE) {
- + (void)fprintf(stderr,
- + "%s: Error opening file '%s'. Last error was %d.\n",
- + progname,
- + filename,
- + GetLastError());
- + return EXIT_FAILURE;
- + }
- +
- + ok = GetFileInformationByHandleEx(fileHandle, FileStandardInfo, &finfo,
- + sizeof(finfo));
- +
- + if (!ok) {
- + (void)fprintf(stderr, "%s: GetFileInformationByHandleEx() "
- + "error. GetLastError()==%d.\n",
- + progname,
- + GetLastError());
- + res = EXIT_FAILURE;
- + goto done;
- + }
- +
- + (void)printf("(\n");
- + (void)printf("\tfilename='%s'\n", filename);
- +
- + (void)printf("\tAllocationSize=%lld\n", (long long)finfo.AllocationSize.QuadPart);
- + (void)printf("\tEndOfFile=%lld\n", (long long)finfo.EndOfFile.QuadPart);
- + (void)printf("\tNumberOfLinks=%ld\n", (long)finfo.NumberOfLinks);
- + (void)printf("\tDeletePending=%s\n", finfo.DeletePending?"true":"false");
- + (void)printf("\tDirectory=%s\n", finfo.Directory?"true":"false");
- + (void)printf(")\n");
- + res = EXIT_SUCCESS;
- +
- +done:
- + CloseHandle(fileHandle);
- + return res;
- +}
- +
- +static
- +void usage(void)
- +{
- + (void)fprintf(stderr, "winfsinfo <getvolumeinfo|filebasicinfo|filestandardinfo> path\n");
- }
- int main(int ac, char *av[])
- {
- - print_volume_info(av[0], av[1]);
- + const char *subcmd;
- +
- + if (ac < 3) {
- + usage();
- + return 2;
- + }
- +
- + subcmd = av[1];
- +
- + if (!strcmp(subcmd, "getvolumeinfo")) {
- + return getvolumeinfo(av[0], av[2]);
- + }
- + else if (!strcmp(subcmd, "filebasicinfo")) {
- + return get_file_basic_info(av[0], av[2]);
- + }
- + else if (!strcmp(subcmd, "filestandardinfo")) {
- + return get_file_standard_info(av[0], av[2]);
- + }
- + else {
- + (void)fprintf(stderr, "%s: Unknown subcmd '%s'\n", av[0], subcmd);
- + return EXIT_FAILURE;
- + }
- +
- return EXIT_SUCCESS;
- }
- --
- 2.43.0
- From 22cb8e3c199312686482592bd6f92e3f67e2f6d9 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 13 Apr 2024 11:54:00 +0200
- Subject: [PATCH 2/3] daemon: Set Win32 timestamps to 0 if matching
- |FATTR4_WORD1_TIME_*| is not provided
- Set Win32 timestamps { |CreationTime|, |LastAccessTime|,
- |LastWriteTime|, |ChangeTime| } to |0| if NFSv4.1 dir info or getattr
- do not return information for them (e.g. one or more of
- |FATTR4_WORD1_TIME_CREATE|, |FATTR4_WORD1_TIME_ACCESS|,
- |FATTR4_WORD1_TIME_MODIFY| not being set).
- This can happen for example with NFSv4.1 servers which do not support
- |FATTR4_WORD1_TIME_CREATE|, or filesystems being exported by the NFS
- server which do not support access timestamps etc.
- This avoids that we invent timestamp information which does not
- exists.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/README.bintarball.txt | 2 +
- daemon/getattr.c | 4 +-
- daemon/name_cache.c | 26 +++++++----
- daemon/nfs41_xdr.c | 1 +
- daemon/open.c | 6 +--
- daemon/readdir.c | 52 ++++++++++++++++++----
- daemon/util.c | 83 ++++++++++++++++++++++++++++++++----
- daemon/util.h | 11 +++++
- 8 files changed, 155 insertions(+), 30 deletions(-)
- diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
- index cc275d1..bc0209d 100644
- --- a/cygwin/README.bintarball.txt
- +++ b/cygwin/README.bintarball.txt
- @@ -283,6 +283,8 @@ $ /sbin/nfs_mount
- - Does not allow renaming a file on top of an existing open file.
- Connectathon's special test op_ren has been commented out.
- +- File access timestamps might be wrong for delegations.
- +
- - Extended attributes are supported with some limitations:
- a) the server must support NFS Named Attributes,
- b) the order of listings cannot be guaranteed by NFS, and
- diff --git a/daemon/getattr.c b/daemon/getattr.c
- index 6708702..9cf1852 100644
- --- a/daemon/getattr.c
- +++ b/daemon/getattr.c
- @@ -149,7 +149,7 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
- switch (args->query_class) {
- case FileBasicInformation:
- - nfs_to_basic_info(&info, &args->basic_info);
- + nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
- args->ctime = info.change;
- break;
- case FileStandardInformation:
- @@ -164,7 +164,7 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
- args->intr_info.IndexNumber.QuadPart = info.fileid;
- break;
- case FileNetworkOpenInformation:
- - nfs_to_network_openinfo(&info, &args->network_info);
- + nfs_to_network_openinfo(state->file.name.name, &info, &args->network_info);
- break;
- default:
- eprintf("unhandled file query class %d\n", args->query_class);
- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index 6e9f7bc..284fc2f 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -3,6 +3,7 @@
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- + * Roland Mainz <roland.mainz@nrubsig.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- @@ -339,14 +340,31 @@ static void copy_attrs(
- OUT nfs41_file_info *dst,
- IN const struct attr_cache_entry *src)
- {
- + dst->attrmask.count = 2;
- + dst->attrmask.arr[0] = FATTR4_WORD0_TYPE | FATTR4_WORD0_CHANGE
- + | FATTR4_WORD0_SIZE | FATTR4_WORD0_FILEID
- + | FATTR4_WORD0_HIDDEN | FATTR4_WORD0_ARCHIVE;
- + dst->attrmask.arr[1] = FATTR4_WORD1_MODE
- + | FATTR4_WORD1_NUMLINKS
- + | FATTR4_WORD1_SYSTEM;
- +
- dst->change = src->change;
- dst->size = src->size;
- + if (!((src->time_access_s == 0) && (src->time_access_ns == 0))) {
- + dst->attrmask.arr[1] |= FATTR4_WORD1_TIME_ACCESS;
- dst->time_access.seconds = src->time_access_s;
- dst->time_access.nseconds = src->time_access_ns;
- + }
- + if (!((src->time_create_s == 0) && (src->time_create_ns == 0))) {
- + dst->attrmask.arr[1] |= FATTR4_WORD1_TIME_CREATE;
- dst->time_create.seconds = src->time_create_s;
- dst->time_create.nseconds = src->time_create_ns;
- + }
- + if (!((src->time_modify_s == 0) && (src->time_modify_ns == 0))) {
- + dst->attrmask.arr[1] |= FATTR4_WORD1_TIME_MODIFY;
- dst->time_modify.seconds = src->time_modify_s;
- dst->time_modify.nseconds = src->time_modify_ns;
- + }
- dst->type = src->type;
- dst->numlinks = src->numlinks;
- dst->mode = src->mode;
- @@ -373,14 +391,6 @@ static void copy_attrs(
- dst->system = src->system;
- dst->archive = src->archive;
- - dst->attrmask.count = 2;
- - dst->attrmask.arr[0] = FATTR4_WORD0_TYPE | FATTR4_WORD0_CHANGE
- - | FATTR4_WORD0_SIZE | FATTR4_WORD0_FILEID
- - | FATTR4_WORD0_HIDDEN | FATTR4_WORD0_ARCHIVE;
- - dst->attrmask.arr[1] = FATTR4_WORD1_MODE
- - | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_TIME_ACCESS
- - | FATTR4_WORD1_TIME_CREATE | FATTR4_WORD1_TIME_MODIFY
- - | FATTR4_WORD1_SYSTEM;
- if (dst->owner)
- dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER;
- if (dst->owner_group)
- diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
- index 90f0e61..1b0abf1 100644
- --- a/daemon/nfs41_xdr.c
- +++ b/daemon/nfs41_xdr.c
- @@ -2344,6 +2344,7 @@ static bool_t decode_readdir_entry(
- xdrmem_create(&fattr_xdr, (char *)attrs.attr_vals, attrs.attr_vals_len, XDR_DECODE);
- if (!(decode_file_attrs(&fattr_xdr, &attrs, &entry->attr_info)))
- entry->attr_info.rdattr_error = NFS4ERR_BADXDR;
- + (void)memcpy(&entry->attr_info.attrmask, &attrs.attrmask, sizeof(bitmap4));
- StringCchCopyA(entry->name, name_len, (STRSAFE_LPCSTR)name);
- it->buf_pos += (size_t)entry_len + name_len;
- diff --git a/daemon/open.c b/daemon/open.c
- index 15c9c28..b9739da 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -745,7 +745,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- status = map_symlink_errors(status);
- goto out_free_state;
- }
- - nfs_to_basic_info(&info, &args->basic_info);
- + nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
- nfs_to_standard_info(&info, &args->std_info);
- args->mode = info.mode;
- args->changeattr = info.change;
- @@ -756,7 +756,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- goto out_free_state;
- }
- - nfs_to_basic_info(&info, &args->basic_info);
- + nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
- nfs_to_standard_info(&info, &args->std_info);
- args->mode = info.mode;
- args->changeattr = info.change;
- @@ -941,7 +941,7 @@ supersede_retry:
- status = nfs_to_windows_error(status, ERROR_FILE_NOT_FOUND);
- goto out_free_state;
- } else {
- - nfs_to_basic_info(&info, &args->basic_info);
- + nfs_to_basic_info(state->file.name.name, &info, &args->basic_info);
- nfs_to_standard_info(&info, &args->std_info);
- args->mode = info.mode;
- args->changeattr = info.change;
- diff --git a/daemon/readdir.c b/daemon/readdir.c
- index 07607ef..31d7047 100644
- --- a/daemon/readdir.c
- +++ b/daemon/readdir.c
- @@ -3,6 +3,7 @@
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- + * Roland Mainz <roland.mainz@nrubsig.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- @@ -323,15 +324,50 @@ static void readdir_copy_dir_info(
- IN PFILE_DIR_INFO_UNION info)
- {
- info->fdi.FileIndex = (ULONG)entry->attr_info.fileid;
- - nfs_time_to_file_time(&entry->attr_info.time_create,
- - &info->fdi.CreationTime);
- - nfs_time_to_file_time(&entry->attr_info.time_access,
- - &info->fdi.LastAccessTime);
- - nfs_time_to_file_time(&entry->attr_info.time_modify,
- - &info->fdi.LastWriteTime);
- +
- + uint32_t attrmask_arr1 = entry->attr_info.attrmask.arr[1];
- +
- + if (attrmask_arr1 & FATTR4_WORD1_TIME_CREATE) {
- + nfs_time_to_file_time(&entry->attr_info.time_create,
- + &info->fdi.CreationTime);
- + }
- + else {
- + DPRINTF(1, ("readdir_copy_dir_info(entry->name='%s'): "
- + "time_create not set\n", entry->name));
- + info->fdi.CreationTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- + if (attrmask_arr1 & FATTR4_WORD1_TIME_ACCESS) {
- + nfs_time_to_file_time(&entry->attr_info.time_access,
- + &info->fdi.LastAccessTime);
- + }
- + else {
- + DPRINTF(1, ("readdir_copy_dir_info(entry->name='%s'): "
- + "time_access not set\n", entry->name));
- + info->fdi.LastAccessTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- + if (attrmask_arr1 & FATTR4_WORD1_TIME_MODIFY) {
- + nfs_time_to_file_time(&entry->attr_info.time_modify,
- + &info->fdi.LastWriteTime);
- + }
- + else {
- + DPRINTF(1, ("readdir_copy_dir_info(entry->name='%s'): "
- + "time_modify not set\n", entry->name));
- + info->fdi.LastWriteTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- /* XXX: was using 'change' attr, but that wasn't giving a time */
- - nfs_time_to_file_time(&entry->attr_info.time_modify,
- - &info->fdi.ChangeTime);
- + if (attrmask_arr1 & FATTR4_WORD1_TIME_MODIFY) {
- + nfs_time_to_file_time(&entry->attr_info.time_modify,
- + &info->fdi.ChangeTime);
- + }
- + else {
- + DPRINTF(1, ("readdir_copy_dir_info(entry->name='%s'): "
- + "time_modify2 not set\n", entry->name));
- + info->fdi.ChangeTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- info->fdi.EndOfFile.QuadPart =
- info->fdi.AllocationSize.QuadPart =
- entry->attr_info.size;
- diff --git a/daemon/util.c b/daemon/util.c
- index 382944a..2c78e9e 100644
- --- a/daemon/util.c
- +++ b/daemon/util.c
- @@ -164,14 +164,47 @@ ULONG nfs_file_info_to_attributes(
- }
- void nfs_to_basic_info(
- + IN const char *name,
- IN const nfs41_file_info *info,
- OUT PFILE_BASIC_INFO basic_out)
- {
- - nfs_time_to_file_time(&info->time_create, &basic_out->CreationTime);
- - nfs_time_to_file_time(&info->time_access, &basic_out->LastAccessTime);
- - nfs_time_to_file_time(&info->time_modify, &basic_out->LastWriteTime);
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_CREATE) {
- + nfs_time_to_file_time(&info->time_create, &basic_out->CreationTime);
- + }
- + else {
- + DPRINTF(1, ("nfs_to_basic_info(name='%s'): "
- + "time_create not set\n", name));
- + basic_out->CreationTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_ACCESS) {
- + nfs_time_to_file_time(&info->time_access, &basic_out->LastAccessTime);
- + }
- + else {
- + DPRINTF(1, ("nfs_to_basic_info(name='%s'): "
- + "time_access not set\n", name));
- + basic_out->LastAccessTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_MODIFY) {
- + nfs_time_to_file_time(&info->time_modify, &basic_out->LastWriteTime);
- + }
- + else {
- + DPRINTF(1, ("nfs_to_basic_info(name='%s'): "
- + "time_modify not set\n", name));
- + basic_out->LastWriteTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- /* XXX: was using 'change' attr, but that wasn't giving a time */
- - nfs_time_to_file_time(&info->time_modify, &basic_out->ChangeTime);
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_MODIFY) {
- + nfs_time_to_file_time(&info->time_modify, &basic_out->ChangeTime);
- + }
- + else {
- + DPRINTF(1, ("nfs_to_basic_info(name='%s'): "
- + "time_modify2 not set\n", name));
- + basic_out->ChangeTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- basic_out->FileAttributes = nfs_file_info_to_attributes(info);
- }
- @@ -190,15 +223,47 @@ void nfs_to_standard_info(
- }
- void nfs_to_network_openinfo(
- + IN const char *name,
- IN const nfs41_file_info *info,
- OUT PFILE_NETWORK_OPEN_INFORMATION net_out)
- {
- -
- - nfs_time_to_file_time(&info->time_create, &net_out->CreationTime);
- - nfs_time_to_file_time(&info->time_access, &net_out->LastAccessTime);
- - nfs_time_to_file_time(&info->time_modify, &net_out->LastWriteTime);
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_CREATE) {
- + nfs_time_to_file_time(&info->time_create, &net_out->CreationTime);
- + }
- + else {
- + DPRINTF(1, ("nfs_to_network_openinfo(name='%s'): "
- + "time_create not set\n", name));
- + net_out->CreationTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_ACCESS) {
- + nfs_time_to_file_time(&info->time_access, &net_out->LastAccessTime);
- + }
- + else {
- + DPRINTF(1, ("nfs_to_network_openinfo(name='%s'): "
- + "time_access not set\n", name));
- + net_out->LastAccessTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_MODIFY) {
- + nfs_time_to_file_time(&info->time_modify, &net_out->LastWriteTime);
- + }
- + else {
- + DPRINTF(1, ("nfs_to_network_openinfo(name='%s'): "
- + "time_modify not set\n", name));
- + net_out->LastWriteTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- /* XXX: was using 'change' attr, but that wasn't giving a time */
- - nfs_time_to_file_time(&info->time_modify, &net_out->ChangeTime);
- + if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_MODIFY) {
- + nfs_time_to_file_time(&info->time_modify, &net_out->ChangeTime);
- + }
- + else {
- + DPRINTF(1, ("nfs_to_network_openinfo(name='%s'): "
- + "time_modify2 not set\n", name));
- + net_out->ChangeTime.QuadPart = FILE_INFO_TIME_NOT_SET;
- + }
- +
- net_out->AllocationSize.QuadPart =
- net_out->EndOfFile.QuadPart = (LONGLONG)info->size;
- net_out->FileAttributes = nfs_file_info_to_attributes(info);
- diff --git a/daemon/util.h b/daemon/util.h
- index bc12f55..d54f9dd 100644
- --- a/daemon/util.h
- +++ b/daemon/util.h
- @@ -3,6 +3,7 @@
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- + * Roland Mainz <roland.mainz@nrubsig.org>
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- @@ -32,6 +33,14 @@ struct __nfs41_session;
- struct __nfs41_write_verf;
- enum stable_how4;
- +/*
- + * LargeInteger.QuadPart value to indicate a time value was not
- + * available
- + *
- + * gisburn: FIXME: We need a better header for this
- + */
- +#define FILE_INFO_TIME_NOT_SET (0LL)
- +
- int safe_read(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
- int safe_write(unsigned char **pos, uint32_t *remaining, void *dest, uint32_t dest_len);
- int get_name(unsigned char **pos, uint32_t *remaining, const char **out_name);
- @@ -100,12 +109,14 @@ static __inline void bitmap_intersect(
- ULONG nfs_file_info_to_attributes(
- IN const nfs41_file_info *info);
- void nfs_to_basic_info(
- + IN const char *name,
- IN const nfs41_file_info *info,
- OUT PFILE_BASIC_INFO basic_out);
- void nfs_to_standard_info(
- IN const nfs41_file_info *info,
- OUT PFILE_STANDARD_INFO std_out);
- void nfs_to_network_openinfo(
- + IN const char *name,
- IN const nfs41_file_info *info,
- OUT PFILE_NETWORK_OPEN_INFORMATION std_out);
- void nfs41_file_info_cpy(
- --
- 2.43.0
- From 0b159cd52bd379354caccbe368def82625eca16e Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Sat, 13 Apr 2024 14:18:19 +0200
- Subject: [PATCH 3/3] daemon: name cache should print number of entries on
- creation
- |nfs41_name_cache_create()| should print the number of name cache
- entries on creation.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/name_cache.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index 284fc2f..acf4604 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -798,7 +798,8 @@ int nfs41_name_cache_create(
- struct nfs41_name_cache *cache;
- int status = NO_ERROR;
- - DPRINTF(NCLVL1, ("nfs41_name_cache_create()\n"));
- + DPRINTF(NCLVL1, ("nfs41_name_cache_create() with %ld entries\n",
- + (long)NAME_CACHE_MAX_ENTRIES));
- /* allocate the cache */
- cache = calloc(1, sizeof(struct nfs41_name_cache));
- --
- 2.43.0
msnfs41client: Patches for Win32 timestamps if server has no timestamp data, winfsinfo+misc, 2024-04-13 ...
Posted by Anonymous on Sat 13th Apr 2024 13:25
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.