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-30 13:21:35 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             : #include <libsyscall_intercept_hook_point.h>
      40             : 
      41             : /*
      42             :  * For PowerPC, syscall_no_intercept_wrapper() is defined in the
      43             :  * syscall intercept branch `powerpc` and file
      44             :  * `include/libsyscall_intercept_hook_point.h`
      45             :  */
      46             : #ifndef _ARCH_PPC64
      47             : template <class... Args>
      48             : inline long
      49      403817 : syscall_no_intercept_wrapper(long syscall_number, Args... args) {
      50             :     long result;
      51             :     int error;
      52      403817 :     result = syscall_no_intercept(syscall_number, args...);
      53      404316 :     error = syscall_error_code(result);
      54         499 :     if(error != 0) {
      55         499 :         return -error;
      56             :     }
      57             :     return result;
      58             : }
      59             : #endif
      60             : 
      61             : struct statfs;
      62             : struct linux_dirent;
      63             : struct linux_dirent64;
      64             : 
      65             : namespace gkfs::hook {
      66             : 
      67             : int
      68             : hook_openat(int dirfd, const char* cpath, int flags, mode_t mode);
      69             : 
      70             : int
      71             : hook_close(int fd);
      72             : 
      73             : int
      74             : hook_stat(const char* path, struct stat* buf);
      75             : 
      76             : #ifdef STATX_TYPE
      77             : int
      78             : hook_statx(int dirfd, const char* path, int flags, unsigned int mask,
      79             :            struct statx* buf);
      80             : #endif
      81             : 
      82             : int
      83             : hook_lstat(const char* path, struct stat* buf);
      84             : 
      85             : int
      86             : hook_fstat(unsigned int fd, struct stat* buf);
      87             : 
      88             : int
      89             : hook_fstatat(int dirfd, const char* cpath, struct stat* buf, int flags);
      90             : 
      91             : int
      92             : hook_read(unsigned int fd, void* buf, size_t count);
      93             : 
      94             : int
      95             : hook_pread(unsigned int fd, char* buf, size_t count, loff_t pos);
      96             : 
      97             : int
      98             : hook_readv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt);
      99             : 
     100             : int
     101             : hook_preadv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt,
     102             :             unsigned long pos_l, unsigned long pos_h);
     103             : 
     104             : int
     105             : hook_write(unsigned int fd, const char* buf, size_t count);
     106             : 
     107             : int
     108             : hook_pwrite(unsigned int fd, const char* buf, size_t count, loff_t pos);
     109             : 
     110             : int
     111             : hook_writev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt);
     112             : 
     113             : int
     114             : hook_pwritev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt,
     115             :              unsigned long pos_l, unsigned long pos_h);
     116             : 
     117             : int
     118             : hook_unlinkat(int dirfd, const char* cpath, int flags);
     119             : 
     120             : int
     121             : hook_symlinkat(const char* oldname, int newdfd, const char* newname);
     122             : 
     123             : int
     124             : hook_flock(unsigned long fd, int flags);
     125             : 
     126             : int
     127             : hook_access(const char* path, int mask);
     128             : 
     129             : int
     130             : hook_faccessat(int dirfd, const char* cpath, int mode);
     131             : 
     132             : #ifdef SYS_faccessat2
     133             : int
     134             : hook_faccessat2(int dirfd, const char* cpath, int mode, int flags);
     135             : #endif
     136             : 
     137             : off_t
     138             : hook_lseek(unsigned int fd, off_t offset, unsigned int whence);
     139             : 
     140             : int
     141             : hook_truncate(const char* path, long length);
     142             : 
     143             : int
     144             : hook_ftruncate(unsigned int fd, unsigned long length);
     145             : 
     146             : int
     147             : hook_dup(unsigned int fd);
     148             : 
     149             : int
     150             : hook_dup2(unsigned int oldfd, unsigned int newfd);
     151             : 
     152             : int
     153             : hook_dup3(unsigned int oldfd, unsigned int newfd, int flags);
     154             : 
     155             : int
     156             : hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count);
     157             : 
     158             : int
     159             : hook_getdents64(unsigned int fd, struct linux_dirent64* dirp,
     160             :                 unsigned int count);
     161             : 
     162             : int
     163             : hook_mkdirat(int dirfd, const char* cpath, mode_t mode);
     164             : 
     165             : int
     166             : hook_fchmodat(int dirfd, const char* path, mode_t mode);
     167             : 
     168             : int
     169             : hook_fchmod(unsigned int dirfd, mode_t mode);
     170             : 
     171             : int
     172             : hook_chdir(const char* path);
     173             : 
     174             : int
     175             : hook_fchdir(unsigned int fd);
     176             : 
     177             : int
     178             : hook_getcwd(char* buf, unsigned long size);
     179             : 
     180             : int
     181             : hook_readlinkat(int dirfd, const char* cpath, char* buf, int bufsiz);
     182             : 
     183             : int
     184             : hook_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
     185             : 
     186             : int
     187             : hook_renameat(int olddfd, const char* oldname, int newdfd, const char* newname,
     188             :               unsigned int flags);
     189             : 
     190             : int
     191             : hook_statfs(const char* path, struct statfs* buf);
     192             : 
     193             : int
     194             : hook_fstatfs(unsigned int fd, struct statfs* buf);
     195             : 
     196             : int
     197             : hook_fsync(unsigned int fd);
     198             : 
     199             : int
     200             : hook_getxattr(const char* path, const char* name, void* value, size_t size);
     201             : 
     202             : } // namespace gkfs::hook
     203             : 
     204             : #endif

Generated by: LCOV version 1.16