From 73b2142d178bac8747eb69b68bdd624dcfaabae2 Mon Sep 17 00:00:00 2001 From: FactorialN <8838579+FactorialN@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:13:56 -0800 Subject: [PATCH] this is a test commit for io debug --- include/files.h | 4 +- include/fuse_common.h | 82 ----------------------------------------- lib/files.cpp | 2 + test/CMakeLists.txt | 13 ++++++- test/layer2_API_dir.cpp | 2 + 5 files changed, 18 insertions(+), 85 deletions(-) delete mode 100644 include/fuse_common.h diff --git a/include/files.h b/include/files.h index 9035eec..53b70a3 100644 --- a/include/files.h +++ b/include/files.h @@ -1,6 +1,6 @@ #include #include -#include "fuse_common.h" +#include #include "direntry.h" class FilesOperation { @@ -23,7 +23,7 @@ class FilesOperation { int fischl_mkdir(const char*, mode_t); int fischl_mknod(const char*, mode_t, dev_t);//for special file int fischl_create(const char *, mode_t, struct fuse_file_info *);//for regular file - //int fischl_readdir(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *, enum fuse_readdir_flags); + int fischl_readdir(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *, enum fuse_readdir_flags); int fischl_unlink (const char *); int fischl_open (const char *, struct fuse_file_info *);//open file int fischl_release (const char *, struct fuse_file_info *);//close file diff --git a/include/fuse_common.h b/include/fuse_common.h deleted file mode 100644 index eef2f49..0000000 --- a/include/fuse_common.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef FUSE_COMMON_H_ -#define FUSE_COMMON_H_ - -#include -#include - -/** - * Information about an open file. - * - * File Handles are created by the open, opendir, and create methods and closed - * by the release and releasedir methods. Multiple file handles may be - * concurrently open for the same file. Generally, a client will create one - * file handle per file descriptor, though in some cases multiple file - * descriptors can share a single file handle. - */ -struct fuse_file_info { - /** Open flags. Available in open() and release() */ - int flags; - - /** In case of a write operation indicates if this was caused - by a delayed write from the page cache. If so, then the - context's pid, uid, and gid fields will not be valid, and - the *fh* value may not match the *fh* value that would - have been sent with the corresponding individual write - requests if write caching had been disabled. */ - unsigned int writepage : 1; - - /** Can be filled in by open/create, to use direct I/O on this file. */ - unsigned int direct_io : 1; - - /** Can be filled in by open and opendir. It signals the kernel that any - currently cached data (ie., data that the filesystem provided the - last time the file/directory was open) need not be invalidated when - the file/directory is closed. */ - unsigned int keep_cache : 1; - - /** Can be filled by open/create, to allow parallel direct writes on this - * file */ - unsigned int parallel_direct_writes : 1; - - /** Indicates a flush operation. Set in flush operation, also - maybe set in highlevel lock operation and lowlevel release - operation. */ - unsigned int flush : 1; - - /** Can be filled in by open, to indicate that the file is not - seekable. */ - unsigned int nonseekable : 1; - - /* Indicates that flock locks for this file should be - released. If set, lock_owner shall contain a valid value. - May only be set in ->release(). */ - unsigned int flock_release : 1; - - /** Can be filled in by opendir. It signals the kernel to - enable caching of entries returned by readdir(). Has no - effect when set in other contexts (in particular it does - nothing when set by open()). */ - unsigned int cache_readdir : 1; - - /** Can be filled in by open, to indicate that flush is not needed - on close. */ - unsigned int noflush : 1; - - /** Padding. Reserved for future use*/ - unsigned int padding : 23; - unsigned int padding2 : 32; - - /** File handle id. May be filled in by filesystem in create, - * open, and opendir(). Available in most other file operations on the - * same file handle. */ - uint64_t fh; - - /** Lock owner id. Available in locking operations and flush */ - uint64_t lock_owner; - - /** Requested poll events. Available in ->poll. Only set on kernels - which support it. If unsupported, this field is set to zero. */ - uint32_t poll_events; -}; - -#endif /* FUSE_COMMON_H_ */ diff --git a/lib/files.cpp b/lib/files.cpp index 6a7e07b..876da86 100644 --- a/lib/files.cpp +++ b/lib/files.cpp @@ -1,4 +1,6 @@ //#include "fuse.h" add this when layer3 +#define FUSE_USE_VERSION 31 + #include "files.h" #include #include diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6ec58ff..1d2e61d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -51,7 +51,6 @@ add_executable(${TARGET_DIR_API} # Link Google Test to your test executables target_link_libraries(${TARGET_LAYER0} gtest gtest_main) target_link_libraries(${TARGET_LAYER1_API} gtest gtest_main) -target_link_libraries(${TARGET_LAYER2_API} gtest gtest_main) target_link_libraries(${TARGET_DIR_API} gtest gtest_main) # add test to activate ctest -VV @@ -59,3 +58,15 @@ add_test(NAME ${TARGET_LAYER0} COMMAND sudo ./${TARGET_LAYER0} ${DIR_PLACE}) add_test(NAME ${TARGET_LAYER1_API} COMMAND sudo ./${TARGET_LAYER1_API} ${DIR_PLACE}) add_test(NAME ${TARGET_LAYER2_API} COMMAND sudo ./${TARGET_LAYER2_API} ${DIR_PLACE}) add_test(NAME ${TARGET_DIR_API} COMMAND sudo ./${TARGET_DIR_API} ${DIR_PLACE}) + + +# Add the -Wall flag +target_compile_options(${TARGET_LAYER2_API} PRIVATE -Wall) + +# Use pkg-config to get flags for fuse3 +find_package(PkgConfig REQUIRED) +pkg_search_module(FUSE3 REQUIRED fuse3) + +# Add the flags from pkg-config for fuse3 +target_include_directories(${TARGET_LAYER2_API} PRIVATE ${FUSE3_INCLUDE_DIRS}) +target_link_libraries(${TARGET_LAYER2_API} PRIVATE ${FUSE3_LIBRARIES} gtest gtest_main) \ No newline at end of file diff --git a/test/layer2_API_dir.cpp b/test/layer2_API_dir.cpp index 6d465d3..6e83f33 100644 --- a/test/layer2_API_dir.cpp +++ b/test/layer2_API_dir.cpp @@ -1,3 +1,5 @@ +#define FUSE_USE_VERSION 31 + #include #include #include