diff options
author | Ryo Nakamura <upa@haeena.net> | 2024-02-06 23:09:59 +0900 |
---|---|---|
committer | Ryo Nakamura <upa@haeena.net> | 2024-02-06 23:09:59 +0900 |
commit | 93f155cffe45e1438e316ed84dcd1bd5215c8030 (patch) | |
tree | 06fa8aac9d9cb8f5ff3dd55581b80fc8e53b1a43 /src/fileops.c | |
parent | 4f0669f8f86acb09f10ffb5af273f86d8d6ddd34 (diff) |
add .clang-format from Linux kernel and format sources
The exception is that ColumnLimit is 90.
Diffstat (limited to 'src/fileops.c')
-rw-r--r-- | src/fileops.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/fileops.c b/src/fileops.c index f24b088..5db7906 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -12,7 +12,6 @@ #include <print.h> #include <platform.h> - sftp_session __thread tls_sftp; /* tls_sftp is used *_wrapped() functions */ @@ -25,7 +24,7 @@ static void sftp_err_to_errno(sftp_session sftp) { int sftperr = sftp_get_error(sftp); - switch (sftperr){ + switch (sftperr) { case SSH_FX_OK: case SSH_FX_EOF: errno = 0; @@ -67,7 +66,6 @@ static void sftp_err_to_errno(sftp_session sftp) } } - MDIR *mscp_opendir(const char *path, sftp_session sftp) { MDIR *md; @@ -112,7 +110,6 @@ void mscp_closedir(MDIR *md) free(md); } - struct dirent __thread tls_dirent; /* tls_dirent contains dirent converted from sftp_attributes returned * from sftp_readdir(). This trick is derived from openssh's @@ -161,26 +158,25 @@ int mscp_mkdir(const char *path, mode_t mode, sftp_session sftp) return ret; } - static void sftp_attr_to_stat(sftp_attributes attr, struct stat *st) { - memset(st, 0, sizeof(*st)); - st->st_size = attr->size; - st->st_uid = attr->uid; - st->st_gid = attr->gid; - st->st_mode = attr->permissions; + memset(st, 0, sizeof(*st)); + st->st_size = attr->size; + st->st_uid = attr->uid; + st->st_gid = attr->gid; + st->st_mode = attr->permissions; #if defined(__APPLE__) -#define st_atim st_atimespec -#define st_mtim st_mtimespec -#define st_ctim st_ctimespec +#define st_atim st_atimespec +#define st_mtim st_mtimespec +#define st_ctim st_ctimespec #endif - st->st_atim.tv_sec = attr->atime; - st->st_atim.tv_nsec = attr->atime_nseconds; - st->st_mtim.tv_sec = attr->mtime; - st->st_mtim.tv_nsec = attr->mtime_nseconds; - st->st_ctim.tv_sec = attr->createtime; - st->st_ctim.tv_nsec = attr->createtime_nseconds; + st->st_atim.tv_sec = attr->atime; + st->st_atim.tv_nsec = attr->atime_nseconds; + st->st_mtim.tv_sec = attr->mtime; + st->st_mtim.tv_nsec = attr->mtime_nseconds; + st->st_ctim.tv_sec = attr->createtime; + st->st_ctim.tv_nsec = attr->createtime_nseconds; switch (attr->type) { case SSH_FILEXFER_TYPE_REGULAR: @@ -203,7 +199,6 @@ static void sftp_attr_to_stat(sftp_attributes attr, struct stat *st) } } - int mscp_stat(const char *path, struct stat *st, sftp_session sftp) { sftp_attributes attr; @@ -256,7 +251,6 @@ int mscp_lstat_wrapped(const char *path, struct stat *st) return mscp_lstat(path, st, tls_sftp); } - mf *mscp_open(const char *path, int flags, mode_t mode, sftp_session sftp) { mf *f; @@ -316,7 +310,7 @@ int mscp_setstat(const char *path, struct stat *st, bool preserve_ts, sftp_sessi memset(&attr, 0, sizeof(attr)); attr.permissions = st->st_mode; attr.size = st->st_size; - attr.flags = (SSH_FILEXFER_ATTR_PERMISSIONS|SSH_FILEXFER_ATTR_SIZE); + attr.flags = (SSH_FILEXFER_ATTR_PERMISSIONS | SSH_FILEXFER_ATTR_SIZE); if (preserve_ts) { attr.atime = st->st_atim.tv_sec; attr.atime_nseconds = st->st_atim.tv_nsec; @@ -357,7 +351,7 @@ int mscp_glob(const char *pattern, int flags, glob_t *pglob, sftp_session sftp) set_tls_sftp_session(sftp); #if defined(__APPLE__) || defined(__FreeBSD__) pglob->gl_opendir = (void *(*)(const char *))mscp_opendir_wrapped; - pglob->gl_readdir = (struct dirent *(*)(void *))mscp_readdir; + pglob->gl_readdir = (struct dirent * (*)(void *)) mscp_readdir; pglob->gl_closedir = (void (*)(void *))mscp_closedir; pglob->gl_lstat = mscp_lstat_wrapped; pglob->gl_stat = mscp_stat_wrapped; |