Commit f013bd35 authored by Ramon Nou's avatar Ramon Nou
Browse files

style: apply clang-format via check_format.sh

parent 8ce6d9f5
Loading
Loading
Loading
Loading
Loading
+12 −6
Changes for src/client/gkfs_libc.cpp: 12 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -2267,7 +2267,8 @@ symlink(const char* path1, const char* path2) throw() {
    gkfs_init_routine_placeholder();
    if(GKFS_INTERCEPTION_ENABLED()) {
        std::string resolved2;
        if(resolve_gkfs_path(AT_FDCWD, path2, resolved2) == PathStatus::Internal) {
        if(resolve_gkfs_path(AT_FDCWD, path2, resolved2) ==
           PathStatus::Internal) {
            DEBUG_INFO("[GKFS] path 2 internal {}", resolved2);
            if(!gkfs::config::metadata::symlink_support) {
                DEBUG_INFO("[GKFS] symlinks not supported/compiled");
@@ -2277,14 +2278,16 @@ symlink(const char* path1, const char* path2) throw() {
            std::string resolved;
            if(path1[0] != '/') {
                std::string parent_dir = gkfs::path::dirname(resolved2);
                std::string abs_target = gkfs::path::prepend_path(parent_dir, path1);
                std::string abs_target =
                        gkfs::path::prepend_path(parent_dir, path1);
                if(abs_target.empty() || abs_target.front() != '/') {
                    resolved = "/" + abs_target;
                } else {
                    resolved = abs_target;
                }
                return gkfs::syscall::gkfs_mk_symlink(resolved2, resolved);
            } else if(resolve_gkfs_path(AT_FDCWD, path1, resolved) == PathStatus::Internal) {
            } else if(resolve_gkfs_path(AT_FDCWD, path1, resolved) ==
                      PathStatus::Internal) {
                return gkfs::syscall::gkfs_mk_symlink(resolved2, resolved);
            } else {
                return gkfs::syscall::gkfs_mk_symlink(resolved2, path1);
@@ -2300,7 +2303,8 @@ symlinkat(const char* path1, int newdirfd, const char* path2) throw() {
    gkfs_init_routine_placeholder();
    if(GKFS_INTERCEPTION_ENABLED()) {
        std::string resolved2;
        if(resolve_gkfs_path(newdirfd, path2, resolved2) == PathStatus::Internal) {
        if(resolve_gkfs_path(newdirfd, path2, resolved2) ==
           PathStatus::Internal) {
            DEBUG_INFO("[GKFS] path 2 internal {}", resolved2);
            if(!gkfs::config::metadata::symlink_support) {
                DEBUG_INFO("[GKFS] symlinks not supported/compiled");
@@ -2310,14 +2314,16 @@ symlinkat(const char* path1, int newdirfd, const char* path2) throw() {
            std::string resolved;
            if(path1[0] != '/') {
                std::string parent_dir = gkfs::path::dirname(resolved2);
                std::string abs_target = gkfs::path::prepend_path(parent_dir, path1);
                std::string abs_target =
                        gkfs::path::prepend_path(parent_dir, path1);
                if(abs_target.empty() || abs_target.front() != '/') {
                    resolved = "/" + abs_target;
                } else {
                    resolved = abs_target;
                }
                return gkfs::syscall::gkfs_mk_symlink(resolved2, resolved);
            } else if(resolve_gkfs_path(AT_FDCWD, path1, resolved) == PathStatus::Internal) {
            } else if(resolve_gkfs_path(AT_FDCWD, path1, resolved) ==
                      PathStatus::Internal) {
                return gkfs::syscall::gkfs_mk_symlink(resolved2, resolved);
            } else {
                return gkfs::syscall::gkfs_mk_symlink(resolved2, path1);
+6 −5
Changes for src/client/gkfs_metadata.cpp: 6 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -326,8 +326,8 @@ gkfs_open_impl(const std::string& path, mode_t mode, int flags,
        std::string rel_target;
        if(!CTX->relativize_path(md.target_path().c_str(), rel_target)) {
            // External target (e.g. /usr/bin/python3): open on host filesystem
            return ::syscall(SYS_openat, AT_FDCWD, md.target_path().c_str(), flags,
                             mode);
            return ::syscall(SYS_openat, AT_FDCWD, md.target_path().c_str(),
                             flags, mode);
        }
        return gkfs_open_impl(rel_target, mode, flags, symlink_depth + 1);
    }
@@ -1638,9 +1638,10 @@ gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp,
 */
int
gkfs_mk_symlink(const std::string& path, const std::string& target_path) {
    /* In standard POSIX symlink(2), the target is arbitrary text and is not verified
     * at symlink creation time. Allowing directory targets enables virtual environments
     * (e.g. lib64 -> lib) and standard software distributions.
    /* In standard POSIX symlink(2), the target is arbitrary text and is not
     * verified at symlink creation time. Allowing directory targets enables
     * virtual environments (e.g. lib64 -> lib) and standard software
     * distributions.
     */
    auto target_md = gkfs::utils::get_metadata(target_path, false);
    (void) target_md;
+6 −4
Changes for src/client/hooks.cpp: 6 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -642,7 +642,8 @@ hook_symlinkat(const char* oldname, int newdfd, const char* newname) {
                        gkfs::path::prepend_path(parent_dir, oldname);
                if(abs_internal_target.empty() ||
                   abs_internal_target.front() != gkfs::path::separator) {
                    oldname_resolved = gkfs::path::separator + abs_internal_target;
                    oldname_resolved =
                            gkfs::path::separator + abs_internal_target;
                } else {
                    oldname_resolved = abs_internal_target;
                }
@@ -653,7 +654,8 @@ hook_symlinkat(const char* oldname, int newdfd, const char* newname) {
                return with_errno(gkfs::syscall::gkfs_mk_symlink(
                        newname_resolved, oldname_resolved));
            } else {
                // Cross-mount symlink pointing to an external host path (e.g. /usr/bin/python3).
                // Cross-mount symlink pointing to an external host path (e.g.
                // /usr/bin/python3).
                return with_errno(gkfs::syscall::gkfs_mk_symlink(
                        newname_resolved, oldname));
            }
@@ -1068,8 +1070,8 @@ hook_chdir(const char* path) {
        if(!rel_path.empty() && rel_path != "/") {
            auto md = gkfs::utils::get_metadata(rel_path);
            if(!md) {
                LOG(DEBUG, "{}() path {} / {} errno {}", __func__, path, rel_path,
                    errno);
                LOG(DEBUG, "{}() path {} / {} errno {}", __func__, path,
                    rel_path, errno);
                return -errno;
            }

+4 −2
Changes for src/client/intercept.cpp: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -699,7 +699,8 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4,
                        if(md->is_link()) {
                            std::string target = md->target_path();
                            std::string next_rel;
                            if(!CTX->relativize_path(target.c_str(), next_rel)) {
                            if(!CTX->relativize_path(target.c_str(),
                                                     next_rel)) {
                                resolved_exec = target;
                                break;
                            }
@@ -740,7 +741,8 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4,
                        if(md->is_link()) {
                            std::string target = md->target_path();
                            std::string next_rel;
                            if(!CTX->relativize_path(target.c_str(), next_rel)) {
                            if(!CTX->relativize_path(target.c_str(),
                                                     next_rel)) {
                                resolved_exec = target;
                                break;
                            }
+4 −3
Changes for src/client/preload_util.cpp: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -354,7 +354,8 @@ get_metadata(const string& path, bool follow_links, bool include_inline) {
        while(md.is_link()) {
            std::string rel_target;
            if(!CTX->relativize_path(md.target_path().c_str(), rel_target)) {
                // External target (e.g. /usr/bin/python3): stat directly on host
                // External target (e.g. /usr/bin/python3): stat directly on
                // host
                struct stat host_st{};
                if(::stat(md.target_path().c_str(), &host_st) != 0) {
                    return {};
@@ -371,8 +372,8 @@ get_metadata(const string& path, bool follow_links, bool include_inline) {
            if(gkfs::config::proxy::fwd_stat && CTX->use_proxy()) {
                err = gkfs::rpc::forward_stat_proxy(rel_target, attr);
            } else {
                err = gkfs::rpc::forward_stat(rel_target, attr,
                                              inline_data, 0, include_inline);
                err = gkfs::rpc::forward_stat(rel_target, attr, inline_data, 0,
                                              include_inline);
            }
            if(err) {
                errno = err;
Loading