void DoExtDiskSpace(tBuffer *bIn, tBuffer *bOut, u_int32_t id) { struct STATFS stfs; tFSPath *realPath; char *path; path = convertFromUtf8(BufferGetString(bIn), 1); realPath = FSCheckPath(path); DEBUG((MYLOG_DEBUG, "[DoExtDiskSpaceOpenSSH]Path: %s", path)); if (realPath != NULL && !HAS_BIT(gl_var->flagsDisable, SFTP_DISABLE_STATSFS)) { DEBUG((MYLOG_DEBUG, "[DoExtDiskSpaceOpenSSH]Realpath: %s", realPath->realPath)); if (STATFS(realPath->realPath, &stfs) == 0) { tBuffer *b; b = BufferNew(); BufferPutInt8(b, SSH2_FXP_EXTENDED_REPLY); BufferPutInt32(b, id); BufferPutInt64(b, (u_int64_t) stfs.f_blocks * (u_int64_t) stfs.f_bsize); BufferPutInt64(b, (u_int64_t) stfs.f_bfree * (u_int64_t) stfs.f_bsize); BufferPutInt64(b, 0); BufferPutInt64(b, (u_int64_t) stfs.f_bavail * (u_int64_t) stfs.f_bsize); BufferPutInt32(b, stfs.f_bsize); BufferPutPacket(bOut, b); } else SendStatus(bOut, id, errnoToPortable(errno)); } else SendStatus(bOut, id, SSH2_FX_PERMISSION_DENIED); FSDestroyPath(realPath); free(path); }
void DoAdminServerGetStatus() { struct stat st; tBuffer *b; char state; b = BufferNew(); BufferPutInt8FAST(b, SSH_ADMIN_SERVER_GET_STATUS_REPLY); if (stat(SHUTDOWN_FILE, &st) == -1) state = 1; else state = 0; BufferPutInt8(b, state); BufferPutPacket(bOut, b); BufferDelete(b); DEBUG((MYLOG_DEBUG, "[DoAdminServerGetStatus]state:'%i'", state)); }
static void DoExtDiskSpaceOpenSSH_Path(tBuffer *bOut, u_int32_t id, const char *path) { struct STATFS stfs; tFSPath *realPath; DEBUG((MYLOG_DEBUG, "[DoExtDiskSpaceOpenSSH_Path]Path: %s", path)); realPath = FSCheckPath(path); if (realPath != NULL && !HAS_BIT(gl_var->flagsDisable, SFTP_DISABLE_STATSFS)) { DEBUG((MYLOG_DEBUG, "[DoExtDiskSpaceOpenSSH_Path]Realpath: %s", realPath->realPath)); if (STATFS(realPath->realPath, &stfs) == 0) { tBuffer *b; b = BufferNew(); BufferPutInt8(b, SSH2_FXP_EXTENDED_REPLY); BufferPutInt32(b, id); BufferPutInt64(b, stfs.f_bsize); /* file system block size */ BufferPutInt64(b, stfs.f_frsize); /* fundamental fs block size */ BufferPutInt64(b, stfs.f_blocks); /* number of blocks (unit f_frsize) */ BufferPutInt64(b, stfs.f_bfree); /* free blocks in file system */ BufferPutInt64(b, stfs.f_bavail); /* free blocks for non-root */ BufferPutInt64(b, stfs.f_files); /* total file inodes */ BufferPutInt64(b, stfs.f_ffree); /* free file inodes */ BufferPutInt64(b, stfs.f_favail); /* free file inodes for to non-root */ BufferPutInt64(b, stfs.f_fsid); /* file system id */ BufferPutInt64(b, stfs.f_flag); /* bit mask of f_flag values */ BufferPutInt64(b, stfs.f_namemax); /* maximum filename length */ BufferPutPacket(bOut, b); BufferDelete(b); } else { DEBUG((MYLOG_DEBUG, "[DoExtDiskSpaceOpenSSH_Path]error: %s", strerror(errno))); SendStatus(bOut, id, errnoToPortable(errno)); } } else { DEBUG((MYLOG_DEBUG, "[DoExtDiskSpaceOpenSSH_Path]FSCheckPath failed")); SendStatus(bOut, id, SSH2_FX_PERMISSION_DENIED); } FSDestroyPath(realPath); }