LCOV - code coverage report
Current view: top level - include/client - hooks.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 5 100.0 %
Date: 2024-04-23 00:09:24 Functions: 25 47 53.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   Copyright 2018-2024, Barcelona Supercomputing Center (BSC), Spain
       3             :   Copyright 2015-2024, Johannes Gutenberg Universitaet Mainz, Germany
       4             : 
       5             :   This software was partially supported by the
       6             :   EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).
       7             : 
       8             :   This software was partially supported by the
       9             :   ADA-FS project under the SPPEXA project funded by the DFG.
      10             : 
      11             :   This file is part of GekkoFS' POSIX interface.
      12             : 
      13             :   GekkoFS' POSIX interface is free software: you can redistribute it and/or
      14             :   modify it under the terms of the GNU Lesser General Public License as
      15             :   published by the Free Software Foundation, either version 3 of the License,
      16             :   or (at your option) any later version.
      17             : 
      18             :   GekkoFS' POSIX interface is distributed in the hope that it will be useful,
      19             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      20             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      21             :   GNU Lesser General Public License for more details.
      22             : 
      23             :   You should have received a copy of the GNU Lesser General Public License
      24             :   along with GekkoFS' POSIX interface.  If not, see
      25             :   <https://www.gnu.org/licenses/>.
      26             : 
      27             :   SPDX-License-Identifier: LGPL-3.0-or-later
      28             : */
      29             : 
      30             : #ifndef GEKKOFS_HOOKS_HPP
      31             : #define GEKKOFS_HOOKS_HPP
      32             : 
      33             : extern "C" {
      34             : #include <sys/types.h>
      35             : #include <fcntl.h>
      36             : #include <sys/stat.h>
      37             : #include <sys/syscall.h>
      38             : }
      39             : 
      40             : #ifndef BYPASS_SYSCALL
      41             : #include <libsyscall_intercept_hook_point.h>
      42             : #else
      43             : #include <client/void_syscall_intercept.hpp>
      44             : #endif
      45             : 
      46             : 
      47             : /*
      48             :  * For PowerPC, syscall_no_intercept_wrapper() is defined in the
      49             :  * syscall intercept branch `powerpc` and file
      50             :  * `include/libsyscall_intercept_hook_point.h`
      51             :  */
      52             : #ifndef _ARCH_PPC64
      53             : template <class... Args>
      54             : inline long
      55      425154 : syscall_no_intercept_wrapper(long syscall_number, Args... args) {
      56             :     long result;
      57             :     int error;
      58      425154 :     result = syscall_no_intercept(syscall_number, args...);
      59      425674 :     error = syscall_error_code(result);
      60         520 :     if(error != 0) {
      61         520 :         return -error;
      62             :     }
      63             :     return result;
      64             : }
      65             : #endif
      66             : 
      67             : struct statfs;
      68             : struct linux_dirent;
      69             : struct linux_dirent64;
      70             : 
      71             : namespace gkfs::hook {
      72             : 
      73             : int
      74             : hook_openat(int dirfd, const char* cpath, int flags, mode_t mode);
      75             : 
      76             : int
      77             : hook_close(int fd);
      78             : 
      79             : int
      80             : hook_stat(const char* path, struct stat* buf);
      81             : 
      82             : #ifdef STATX_TYPE
      83             : int
      84             : hook_statx(int dirfd, const char* path, int flags, unsigned int mask,
      85             :            struct statx* buf);
      86             : #endif
      87             : 
      88             : int
      89             : hook_lstat(const char* path, struct stat* buf);
      90             : 
      91             : int
      92             : hook_fstat(unsigned int fd, struct stat* buf);
      93             : 
      94             : int
      95             : hook_fstatat(int dirfd, const char* cpath, struct stat* buf, int flags);
      96             : 
      97             : int
      98             : hook_read(unsigned int fd, void* buf, size_t count);
      99             : 
     100             : int
     101             : hook_pread(unsigned int fd, char* buf, size_t count, loff_t pos);
     102             : 
     103             : int
     104             : hook_readv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt);
     105             : 
     106             : int
     107             : hook_preadv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt,
     108             :             unsigned long pos_l, unsigned long pos_h);
     109             : 
     110             : int
     111             : hook_write(unsigned int fd, const char* buf, size_t count);
     112             : 
     113             : int
     114             : hook_pwrite(unsigned int fd, const char* buf, size_t count, loff_t pos);
     115             : 
     116             : int
     117             : hook_writev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt);
     118             : 
     119             : int
     120             : hook_pwritev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt,
     121             :              unsigned long pos_l, unsigned long pos_h);
     122             : 
     123             : int
     124             : hook_unlinkat(int dirfd, const char* cpath, int flags);
     125             : 
     126             : int
     127             : hook_symlinkat(const char* oldname, int newdfd, const char* newname);
     128             : 
     129             : int
     130             : hook_flock(unsigned long fd, int flags);
     131             : 
     132             : int
     133             : hook_access(const char* path, int mask);
     134             : 
     135             : int
     136             : hook_faccessat(int dirfd, const char* cpath, int mode);
     137             : 
     138             : #ifdef SYS_faccessat2
     139             : int
     140             : hook_faccessat2(int dirfd, const char* cpath, int mode, int flags);
     141             : #endif
     142             : 
     143             : off_t
     144             : hook_lseek(unsigned int fd, off_t offset, unsigned int whence);
     145             : 
     146             : int
     147             : hook_truncate(const char* path, long length);
     148             : 
     149             : int
     150             : hook_ftruncate(unsigned int fd, unsigned long length);
     151             : 
     152             : int
     153             : hook_dup(unsigned int fd);
     154             : 
     155             : int
     156             : hook_dup2(unsigned int oldfd, unsigned int newfd);
     157             : 
     158             : int
     159             : hook_dup3(unsigned int oldfd, unsigned int newfd, int flags);
     160             : 
     161             : int
     162             : hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count);
     163             : 
     164             : int
     165             : hook_getdents64(unsigned int fd, struct linux_dirent64* dirp,
     166             :                 unsigned int count);
     167             : 
     168             : int
     169             : hook_mkdirat(int dirfd, const char* cpath, mode_t mode);
     170             : 
     171             : int
     172             : hook_fchmodat(int dirfd, const char* path, mode_t mode);
     173             : 
     174             : int
     175             : hook_fchmod(unsigned int dirfd, mode_t mode);
     176             : 
     177             : int
     178             : hook_chdir(const char* path);
     179             : 
     180             : int
     181             : hook_fchdir(unsigned int fd);
     182             : 
     183             : int
     184             : hook_getcwd(char* buf, unsigned long size);
     185             : 
     186             : int
     187             : hook_readlinkat(int dirfd, const char* cpath, char* buf, int bufsiz);
     188             : 
     189             : int
     190             : hook_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
     191             : 
     192             : int
     193             : hook_renameat(int olddfd, const char* oldname, int newdfd, const char* newname,
     194             :               unsigned int flags);
     195             : 
     196             : int
     197             : hook_statfs(const char* path, struct statfs* buf);
     198             : 
     199             : int
     200             : hook_fstatfs(unsigned int fd, struct statfs* buf);
     201             : 
     202             : int
     203             : hook_fsync(unsigned int fd);
     204             : 
     205             : int
     206             : hook_getxattr(const char* path, const char* name, void* value, size_t size);
     207             : 
     208             : } // namespace gkfs::hook
     209             : 
     210             : #endif

Generated by: LCOV version 1.16