Loading include/client/syscalls/args.hpp +59 −80 Original line number Diff line number Diff line Loading @@ -84,9 +84,7 @@ struct printable_arg { /** All arg formatters must follow this prototype */ template <typename FmtBuffer> using formatter = std::add_pointer_t<void(FmtBuffer&, const printable_arg&)>; using formatter = std::add_pointer_t<void(FmtBuffer&, const printable_arg&)>; /** forward declare formatters */ Loading Loading @@ -209,9 +207,7 @@ typedef struct { template <typename FmtBuffer, typename FlagDescriptorArray> static void format_flag(FmtBuffer& buffer, long flag, FlagDescriptorArray&& desc) { format_flag(FmtBuffer& buffer, long flag, FlagDescriptorArray&& desc) { // we assume that if a flag value is zero, its printable // name will always be at position 0 in the array Loading @@ -237,9 +233,7 @@ format_flag(FmtBuffer& buffer, template <typename FmtBuffer, typename FlagDescriptorArray> static void format_flag_set(FmtBuffer& buffer, long flags, FlagDescriptorArray&& desc) { format_flag_set(FmtBuffer& buffer, long flags, FlagDescriptorArray&& desc) { // we assume that if a flag value is zero, its printable // name will always be at position 0 in the array Loading Loading @@ -291,8 +285,7 @@ format_flag_set(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_whence_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_whence_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for lseek() whence arg */ const auto flag_names = Loading @@ -315,8 +308,7 @@ format_whence_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_mmap_prot_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_mmap_prot_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for mmap() prot arg */ const auto flag_names = Loading @@ -341,8 +333,7 @@ format_mmap_prot_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_mmap_flags_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_mmap_flags_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for mmap() flags arg */ const auto flag_names = Loading Loading @@ -382,8 +373,7 @@ format_mmap_flags_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_clone_flags_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_clone_flags_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for clone() flags arg */ const auto flag_names = Loading Loading @@ -435,8 +425,7 @@ format_clone_flags_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_signum_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_signum_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for signum args */ const auto flag_names = Loading Loading @@ -490,8 +479,7 @@ format_signum_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_sigproc_how_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_sigproc_how_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for sigproc how args */ const auto flag_names = Loading @@ -513,8 +501,7 @@ format_sigproc_how_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_none_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_none_arg_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "void"); } Loading @@ -527,8 +514,7 @@ format_none_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_fd_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_fd_arg_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "{}={}", parg.name, static_cast<int>(parg.value)); } Loading @@ -541,8 +527,7 @@ format_fd_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_atfd_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_atfd_arg_to(FmtBuffer& buffer, const printable_arg& parg) { if(static_cast<int>(parg.value) == AT_FDCWD) { fmt::format_to(buffer, "{}=AT_FDCWD", parg.name); Loading @@ -561,8 +546,7 @@ format_atfd_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_cstr_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_cstr_arg_to(FmtBuffer& buffer, const printable_arg& parg) { if(LIKELY(reinterpret_cast<const char*>(parg.value) != nullptr)) { fmt::format_to(buffer, "{}=\"{}\"", parg.name, Loading Loading @@ -649,8 +633,7 @@ format_open_flags_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_octal_mode_to(FmtBuffer& buffer, const printable_arg& parg) { format_octal_mode_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "{}={:#04o}", parg.name, parg.value); } Loading @@ -662,8 +645,7 @@ format_octal_mode_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_ptr_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_ptr_arg_to(FmtBuffer& buffer, const printable_arg& parg) { if(LIKELY(reinterpret_cast<const void*>(parg.value) != nullptr)) { fmt::format_to(buffer, "{}={}", parg.name, Loading @@ -683,8 +665,7 @@ format_ptr_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_dec_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_dec_arg_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "{}={}", parg.name, parg.value); } Loading @@ -697,8 +678,7 @@ format_dec_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_dec32_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_dec32_arg_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "{}={}", parg.name, static_cast<int>(parg.value)); } Loading @@ -711,8 +691,7 @@ format_dec32_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_arg_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "{}={:#x}", parg.name, parg.value); } Loading include/client/syscalls/decoder.hpp +7 −19 Original line number Diff line number Diff line Loading @@ -11,9 +11,6 @@ SPDX-License-Identifier: MIT */ // This file uses special C formatting for a better overview // clang-format off #ifndef GKFS_SYSCALLS_DECODER_HPP #define GKFS_SYSCALLS_DECODER_HPP Loading @@ -28,8 +25,7 @@ namespace detail { /** a RAII saver/restorer of errno values */ struct errno_saver { errno_saver(int errnum) : saved_errno_(errnum) { } errno_saver(int errnum) : saved_errno_(errnum) {} ~errno_saver() { errno = saved_errno_; Loading @@ -42,8 +38,7 @@ struct errno_saver { template <typename FmtBuffer> inline void decode(FmtBuffer& buffer, const long syscall_number, decode(FmtBuffer& buffer, const long syscall_number, const long argv[MAX_ARGS]) { detail::errno_saver _(errno); Loading @@ -67,9 +62,7 @@ decode(FmtBuffer& buffer, template <typename FmtBuffer> inline void decode(FmtBuffer& buffer, const long syscall_number, const long argv[MAX_ARGS], decode(FmtBuffer& buffer, const long syscall_number, const long argv[MAX_ARGS], const long result) { detail::errno_saver _(errno); Loading @@ -94,22 +87,17 @@ decode(FmtBuffer& buffer, } if(error_code(result) != 0) { fmt::format_to(buffer, ") = {} {} ({})", static_cast<int>(-1), errno_name(-result), errno_message(-result)); fmt::format_to(buffer, ") = {} {} ({})", static_cast<int>(-1), errno_name(-result), errno_message(-result)); return; } fmt::format_to(buffer, ") = "); const auto& ret = sc.return_type(); ret.formatter<FmtBuffer>()(buffer, result); } } // namespace syscall } // namespace gkfs #endif // GKFS_SYSCALLS_DECODER_HPP No newline at end of file // clang-format on No newline at end of file include/client/syscalls/errno.hpp +533 −533 Original line number Diff line number Diff line Loading @@ -575,7 +575,7 @@ errno_message(int errno_value) { return std::string{msg}; } } // namespace syscalls } // namespace syscall } // namespace gkfs #endif // GKFS_SYSCALLS_ERRNO_HPP include/client/syscalls/syscall.hpp +19 −20 Original line number Diff line number Diff line Loading @@ -71,8 +71,7 @@ lookup_by_number(const long syscall_number) { } static inline descriptor lookup_by_number(const long syscall_number, const long argv[MAX_ARGS]) { lookup_by_number(const long syscall_number, const long argv[MAX_ARGS]) { const auto* info = ::get_syscall_info(syscall_number, argv); return *reinterpret_cast<const descriptor*>(info); } Loading src/client/syscalls/detail/syscall_info.c +14 −17 Original line number Diff line number Diff line Loading @@ -487,8 +487,7 @@ requires_mode_arg(int flags) { * appropriately describes the system call identified by 'syscall_number'. */ const struct syscall_info* get_syscall_info(const long syscall_number, const long* argv) { get_syscall_info(const long syscall_number, const long* argv) { if(syscall_number < 0 || syscall_number >= (long) ARRAY_SIZE(syscall_table)) { Loading Loading @@ -900,8 +899,8 @@ compare_named_entries(const void *k, const void *e) { const struct syscall_info* get_syscall_info_by_name(const char* syscall_name) { struct named_syscall_entry* res = bsearch(syscall_name, &syscalls_by_name[0], ARRAY_SIZE(syscalls_by_name), struct named_syscall_entry* res = bsearch( syscall_name, &syscalls_by_name[0], ARRAY_SIZE(syscalls_by_name), sizeof(struct named_syscall_entry), compare_named_entries); if(res == NULL) { Loading @@ -911,8 +910,7 @@ get_syscall_info_by_name(const char* syscall_name) { return res->s_info; } #define RETURN_TYPE(scinfo) \ (scinfo)->s_return_type.r_type #define RETURN_TYPE(scinfo) (scinfo)->s_return_type.r_type bool syscall_never_returns(long syscall_number) { Loading @@ -920,7 +918,6 @@ syscall_never_returns(long syscall_number) { } #undef SYSCALL #undef S_NOARGS #undef S_UARG Loading Loading
include/client/syscalls/args.hpp +59 −80 Original line number Diff line number Diff line Loading @@ -84,9 +84,7 @@ struct printable_arg { /** All arg formatters must follow this prototype */ template <typename FmtBuffer> using formatter = std::add_pointer_t<void(FmtBuffer&, const printable_arg&)>; using formatter = std::add_pointer_t<void(FmtBuffer&, const printable_arg&)>; /** forward declare formatters */ Loading Loading @@ -209,9 +207,7 @@ typedef struct { template <typename FmtBuffer, typename FlagDescriptorArray> static void format_flag(FmtBuffer& buffer, long flag, FlagDescriptorArray&& desc) { format_flag(FmtBuffer& buffer, long flag, FlagDescriptorArray&& desc) { // we assume that if a flag value is zero, its printable // name will always be at position 0 in the array Loading @@ -237,9 +233,7 @@ format_flag(FmtBuffer& buffer, template <typename FmtBuffer, typename FlagDescriptorArray> static void format_flag_set(FmtBuffer& buffer, long flags, FlagDescriptorArray&& desc) { format_flag_set(FmtBuffer& buffer, long flags, FlagDescriptorArray&& desc) { // we assume that if a flag value is zero, its printable // name will always be at position 0 in the array Loading Loading @@ -291,8 +285,7 @@ format_flag_set(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_whence_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_whence_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for lseek() whence arg */ const auto flag_names = Loading @@ -315,8 +308,7 @@ format_whence_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_mmap_prot_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_mmap_prot_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for mmap() prot arg */ const auto flag_names = Loading @@ -341,8 +333,7 @@ format_mmap_prot_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_mmap_flags_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_mmap_flags_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for mmap() flags arg */ const auto flag_names = Loading Loading @@ -382,8 +373,7 @@ format_mmap_flags_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_clone_flags_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_clone_flags_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for clone() flags arg */ const auto flag_names = Loading Loading @@ -435,8 +425,7 @@ format_clone_flags_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_signum_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_signum_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for signum args */ const auto flag_names = Loading Loading @@ -490,8 +479,7 @@ format_signum_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_sigproc_how_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_sigproc_how_arg_to(FmtBuffer& buffer, const printable_arg& parg) { /* Names for sigproc how args */ const auto flag_names = Loading @@ -513,8 +501,7 @@ format_sigproc_how_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_none_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_none_arg_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "void"); } Loading @@ -527,8 +514,7 @@ format_none_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_fd_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_fd_arg_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "{}={}", parg.name, static_cast<int>(parg.value)); } Loading @@ -541,8 +527,7 @@ format_fd_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_atfd_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_atfd_arg_to(FmtBuffer& buffer, const printable_arg& parg) { if(static_cast<int>(parg.value) == AT_FDCWD) { fmt::format_to(buffer, "{}=AT_FDCWD", parg.name); Loading @@ -561,8 +546,7 @@ format_atfd_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_cstr_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_cstr_arg_to(FmtBuffer& buffer, const printable_arg& parg) { if(LIKELY(reinterpret_cast<const char*>(parg.value) != nullptr)) { fmt::format_to(buffer, "{}=\"{}\"", parg.name, Loading Loading @@ -649,8 +633,7 @@ format_open_flags_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_octal_mode_to(FmtBuffer& buffer, const printable_arg& parg) { format_octal_mode_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "{}={:#04o}", parg.name, parg.value); } Loading @@ -662,8 +645,7 @@ format_octal_mode_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_ptr_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_ptr_arg_to(FmtBuffer& buffer, const printable_arg& parg) { if(LIKELY(reinterpret_cast<const void*>(parg.value) != nullptr)) { fmt::format_to(buffer, "{}={}", parg.name, Loading @@ -683,8 +665,7 @@ format_ptr_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_dec_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_dec_arg_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "{}={}", parg.name, parg.value); } Loading @@ -697,8 +678,7 @@ format_dec_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_dec32_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_dec32_arg_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "{}={}", parg.name, static_cast<int>(parg.value)); } Loading @@ -711,8 +691,7 @@ format_dec32_arg_to(FmtBuffer& buffer, */ template <typename FmtBuffer> inline void format_arg_to(FmtBuffer& buffer, const printable_arg& parg) { format_arg_to(FmtBuffer& buffer, const printable_arg& parg) { fmt::format_to(buffer, "{}={:#x}", parg.name, parg.value); } Loading
include/client/syscalls/decoder.hpp +7 −19 Original line number Diff line number Diff line Loading @@ -11,9 +11,6 @@ SPDX-License-Identifier: MIT */ // This file uses special C formatting for a better overview // clang-format off #ifndef GKFS_SYSCALLS_DECODER_HPP #define GKFS_SYSCALLS_DECODER_HPP Loading @@ -28,8 +25,7 @@ namespace detail { /** a RAII saver/restorer of errno values */ struct errno_saver { errno_saver(int errnum) : saved_errno_(errnum) { } errno_saver(int errnum) : saved_errno_(errnum) {} ~errno_saver() { errno = saved_errno_; Loading @@ -42,8 +38,7 @@ struct errno_saver { template <typename FmtBuffer> inline void decode(FmtBuffer& buffer, const long syscall_number, decode(FmtBuffer& buffer, const long syscall_number, const long argv[MAX_ARGS]) { detail::errno_saver _(errno); Loading @@ -67,9 +62,7 @@ decode(FmtBuffer& buffer, template <typename FmtBuffer> inline void decode(FmtBuffer& buffer, const long syscall_number, const long argv[MAX_ARGS], decode(FmtBuffer& buffer, const long syscall_number, const long argv[MAX_ARGS], const long result) { detail::errno_saver _(errno); Loading @@ -94,22 +87,17 @@ decode(FmtBuffer& buffer, } if(error_code(result) != 0) { fmt::format_to(buffer, ") = {} {} ({})", static_cast<int>(-1), errno_name(-result), errno_message(-result)); fmt::format_to(buffer, ") = {} {} ({})", static_cast<int>(-1), errno_name(-result), errno_message(-result)); return; } fmt::format_to(buffer, ") = "); const auto& ret = sc.return_type(); ret.formatter<FmtBuffer>()(buffer, result); } } // namespace syscall } // namespace gkfs #endif // GKFS_SYSCALLS_DECODER_HPP No newline at end of file // clang-format on No newline at end of file
include/client/syscalls/errno.hpp +533 −533 Original line number Diff line number Diff line Loading @@ -575,7 +575,7 @@ errno_message(int errno_value) { return std::string{msg}; } } // namespace syscalls } // namespace syscall } // namespace gkfs #endif // GKFS_SYSCALLS_ERRNO_HPP
include/client/syscalls/syscall.hpp +19 −20 Original line number Diff line number Diff line Loading @@ -71,8 +71,7 @@ lookup_by_number(const long syscall_number) { } static inline descriptor lookup_by_number(const long syscall_number, const long argv[MAX_ARGS]) { lookup_by_number(const long syscall_number, const long argv[MAX_ARGS]) { const auto* info = ::get_syscall_info(syscall_number, argv); return *reinterpret_cast<const descriptor*>(info); } Loading
src/client/syscalls/detail/syscall_info.c +14 −17 Original line number Diff line number Diff line Loading @@ -487,8 +487,7 @@ requires_mode_arg(int flags) { * appropriately describes the system call identified by 'syscall_number'. */ const struct syscall_info* get_syscall_info(const long syscall_number, const long* argv) { get_syscall_info(const long syscall_number, const long* argv) { if(syscall_number < 0 || syscall_number >= (long) ARRAY_SIZE(syscall_table)) { Loading Loading @@ -900,8 +899,8 @@ compare_named_entries(const void *k, const void *e) { const struct syscall_info* get_syscall_info_by_name(const char* syscall_name) { struct named_syscall_entry* res = bsearch(syscall_name, &syscalls_by_name[0], ARRAY_SIZE(syscalls_by_name), struct named_syscall_entry* res = bsearch( syscall_name, &syscalls_by_name[0], ARRAY_SIZE(syscalls_by_name), sizeof(struct named_syscall_entry), compare_named_entries); if(res == NULL) { Loading @@ -911,8 +910,7 @@ get_syscall_info_by_name(const char* syscall_name) { return res->s_info; } #define RETURN_TYPE(scinfo) \ (scinfo)->s_return_type.r_type #define RETURN_TYPE(scinfo) (scinfo)->s_return_type.r_type bool syscall_never_returns(long syscall_number) { Loading @@ -920,7 +918,6 @@ syscall_never_returns(long syscall_number) { } #undef SYSCALL #undef S_NOARGS #undef S_UARG Loading