mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 02:38:31 +00:00
Add lchown, lchmod, statvfs, fstatvfs
This commit is contained in:
parent
7b74f6e20e
commit
5a632cf72d
24 changed files with 231 additions and 32 deletions
|
@ -122,6 +122,8 @@ int ioprio_set(int, int, int);
|
|||
int issetugid(void);
|
||||
int kill(int, int);
|
||||
int killpg(int, int);
|
||||
int lchmod(const char *, uint32_t);
|
||||
int lchown(const char *, uint32_t, uint32_t);
|
||||
int link(const char *, const char *) dontthrow;
|
||||
int linkat(int, const char *, int, const char *, int);
|
||||
int madvise(void *, uint64_t, int);
|
||||
|
|
|
@ -177,7 +177,8 @@ o//libc/calls/fcntl.o: private \
|
|||
# it's early runtime mandatory and quite huge without it
|
||||
o//libc/calls/getcwd.greg.o \
|
||||
o//libc/calls/getcwd-nt.greg.o \
|
||||
o//libc/calls/getcwd-xnu.greg.o: private \
|
||||
o//libc/calls/getcwd-xnu.greg.o \
|
||||
o//libc/calls/statfs2cosmo.o: private \
|
||||
OVERRIDE_CFLAGS += \
|
||||
-Os
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/fsid.h"
|
||||
#include "libc/calls/struct/statfs.h"
|
||||
#include "libc/calls/struct/statfs.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
|
@ -69,7 +70,7 @@ textwindows int sys_fstatfs_nt(int64_t handle, struct statfs *f) {
|
|||
}
|
||||
f->f_fstypename[j] = 0;
|
||||
f->f_type = h;
|
||||
f->f_fsid = VolumeSerialNumber;
|
||||
f->f_fsid = (fsid_t){{VolumeSerialNumber}};
|
||||
f->f_flags = FileSystemFlags;
|
||||
f->f_bsize = fs.BytesPerSector;
|
||||
f->f_bsize *= fs.SectorsPerAllocationUnit;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
/**
|
||||
* Returns information about filesystem.
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
*/
|
||||
int fstatfs(int fd, struct statfs *sf) {
|
||||
int rc;
|
||||
|
|
37
libc/calls/fstatvfs.c
Normal file
37
libc/calls/fstatvfs.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/statfs.h"
|
||||
#include "libc/calls/struct/statfs.internal.h"
|
||||
#include "libc/calls/struct/statvfs.h"
|
||||
|
||||
/**
|
||||
* Returns information about filesystem.
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @note consider using fstatfs()
|
||||
*/
|
||||
int fstatvfs(int fd, struct statvfs *sv) {
|
||||
struct statfs sf;
|
||||
if (fstatfs(fd, &sf) != -1) {
|
||||
statfs2statvfs(sv, &sf);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
34
libc/calls/lchmod.c
Normal file
34
libc/calls/lchmod.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
|
||||
/**
|
||||
* Changes mode of pathname, w/o dereferencing symlinks.
|
||||
*
|
||||
* @param uid is user id, or -1u to not change
|
||||
* @param gid is group id, or -1u to not change
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @see chown() which dereferences symbolic links
|
||||
* @see /etc/passwd for user ids
|
||||
* @see /etc/group for group ids
|
||||
*/
|
||||
int lchmod(const char *pathname, uint32_t mode) {
|
||||
return fchmodat(AT_FDCWD, pathname, mode, AT_SYMLINK_NOFOLLOW);
|
||||
}
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
/**
|
||||
* Returns information about filesystem.
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
*/
|
||||
int statfs(const char *path, struct statfs *sf) {
|
||||
int rc;
|
||||
|
|
|
@ -197,7 +197,7 @@ void statfs2cosmo(struct statfs *f, const union statfs_meta *m) {
|
|||
int64_t f_bavail;
|
||||
int64_t f_files;
|
||||
int64_t f_ffree;
|
||||
int64_t f_fsid;
|
||||
fsid_t f_fsid;
|
||||
int64_t f_namelen;
|
||||
int64_t f_frsize;
|
||||
int64_t f_flags;
|
||||
|
@ -217,6 +217,7 @@ void statfs2cosmo(struct statfs *f, const union statfs_meta *m) {
|
|||
f_frsize = m->linux.f_frsize;
|
||||
f_flags = m->linux.f_flags;
|
||||
f_owner = 0;
|
||||
bzero(f_fstypename, 16);
|
||||
strcpy(f_fstypename, DescribeStatfsTypeLinux(m->linux.f_type));
|
||||
|
||||
} else if (IsFreebsd()) {
|
||||
|
@ -232,7 +233,7 @@ void statfs2cosmo(struct statfs *f, const union statfs_meta *m) {
|
|||
f_frsize = m->freebsd.f_bsize;
|
||||
f_flags = m->freebsd.f_flags;
|
||||
f_owner = m->freebsd.f_owner;
|
||||
strcpy(f_fstypename, m->freebsd.f_fstypename);
|
||||
memcpy(f_fstypename, m->freebsd.f_fstypename, 16);
|
||||
|
||||
} else if (IsXnu()) {
|
||||
f_type = m->xnu.f_type;
|
||||
|
@ -247,7 +248,7 @@ void statfs2cosmo(struct statfs *f, const union statfs_meta *m) {
|
|||
f_frsize = m->xnu.f_bsize;
|
||||
f_flags = m->xnu.f_flags;
|
||||
f_owner = m->xnu.f_owner;
|
||||
strcpy(f_fstypename, m->xnu.f_fstypename);
|
||||
memcpy(f_fstypename, m->xnu.f_fstypename, 16);
|
||||
|
||||
} else if (IsOpenbsd()) {
|
||||
f_type = f->f_type;
|
||||
|
@ -262,7 +263,7 @@ void statfs2cosmo(struct statfs *f, const union statfs_meta *m) {
|
|||
f_frsize = m->openbsd.f_bsize;
|
||||
f_flags = m->openbsd.f_flags;
|
||||
f_owner = m->openbsd.f_owner;
|
||||
strcpy(f_fstypename, m->openbsd.f_fstypename);
|
||||
memcpy(f_fstypename, m->openbsd.f_fstypename, 16);
|
||||
|
||||
} else if (IsNetbsd()) {
|
||||
f_type = m->netbsd.f_type;
|
||||
|
@ -277,7 +278,7 @@ void statfs2cosmo(struct statfs *f, const union statfs_meta *m) {
|
|||
f_frsize = m->netbsd.f_bsize;
|
||||
f_flags = m->netbsd.f_flags;
|
||||
f_owner = m->netbsd.f_owner;
|
||||
strcpy(f_fstypename, m->netbsd.f_fstypename);
|
||||
memcpy(f_fstypename, m->netbsd.f_fstypename, 16);
|
||||
|
||||
} else {
|
||||
asm("hlt");
|
||||
|
@ -295,5 +296,5 @@ void statfs2cosmo(struct statfs *f, const union statfs_meta *m) {
|
|||
f->f_namelen = f_namelen;
|
||||
f->f_frsize = f_frsize;
|
||||
f->f_flags = f_flags;
|
||||
strcpy(f->f_fstypename, f_fstypename);
|
||||
memcpy(f->f_fstypename, f_fstypename, 16);
|
||||
}
|
||||
|
|
36
libc/calls/statfs2statvfs.c
Normal file
36
libc/calls/statfs2statvfs.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/statfs.h"
|
||||
#include "libc/calls/struct/statvfs.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
void statfs2statvfs(struct statvfs *sv, const struct statfs *sf) {
|
||||
bzero(sv, sizeof(*sv));
|
||||
sv->f_bsize = sf->f_bsize;
|
||||
sv->f_frsize = sf->f_frsize ? sf->f_frsize : sf->f_bsize;
|
||||
sv->f_blocks = sf->f_blocks;
|
||||
sv->f_bfree = sf->f_bfree;
|
||||
sv->f_bavail = sf->f_bavail;
|
||||
sv->f_files = sf->f_files;
|
||||
sv->f_ffree = sf->f_ffree;
|
||||
sv->f_favail = sf->f_ffree;
|
||||
sv->f_fsid = sf->f_fsid.__val[0];
|
||||
sv->f_flag = sf->f_flags;
|
||||
sv->f_namemax = sf->f_namelen;
|
||||
}
|
37
libc/calls/statvfs.c
Normal file
37
libc/calls/statvfs.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/statfs.h"
|
||||
#include "libc/calls/struct/statfs.internal.h"
|
||||
#include "libc/calls/struct/statvfs.h"
|
||||
|
||||
/**
|
||||
* Returns information about filesystem.
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @note consider using statfs()
|
||||
*/
|
||||
int statvfs(const char *path, struct statvfs *sv) {
|
||||
struct statfs sf;
|
||||
if (statfs(path, &sf) != -1) {
|
||||
statfs2statvfs(sv, &sf);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
12
libc/calls/struct/fsid.h
Normal file
12
libc/calls/struct/fsid.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_FSID_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FSID_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
typedef struct fsid_t {
|
||||
uint32_t __val[2];
|
||||
} fsid_t;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_FSID_H_ */
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_FREEBSD_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_FREEBSD_INTERNAL_H_
|
||||
#include "libc/calls/struct/fsid.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
@ -21,7 +22,7 @@ struct statfs_freebsd {
|
|||
uint64_t f_spare[10]; /* unused spare */
|
||||
uint32_t f_namemax; /* maximum filename length */
|
||||
uint32_t f_owner; /* user that mounted the filesystem */
|
||||
uint64_t f_fsid; /* filesystem id (endian 32 matters) */
|
||||
fsid_t f_fsid; /* filesystem id */
|
||||
char f_charspare[80]; /* spare string space */
|
||||
char f_fstypename[16]; /* filesystem type name */
|
||||
char f_mntfromname[1024]; /* mounted filesystem */
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_LINUX_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_LINUX_INTERNAL_H_
|
||||
#include "libc/calls/struct/fsid.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
@ -11,7 +12,7 @@ struct statfs_linux {
|
|||
int64_t f_bavail; /* free blocks available to */
|
||||
int64_t f_files; /* total file nodes in filesystem */
|
||||
int64_t f_ffree; /* free file nodes in filesystem */
|
||||
int64_t f_fsid; /* filesystem id */
|
||||
fsid_t f_fsid; /* filesystem id */
|
||||
int64_t f_namelen; /* maximum length of filenames */
|
||||
int64_t f_frsize; /* fragment size */
|
||||
int64_t f_flags; /* mount flags of filesystem 2.6.36 */
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_NETBSD_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_NETBSD_H_
|
||||
#include "libc/calls/struct/fsid.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
@ -13,7 +14,7 @@ struct statfs_netbsd {
|
|||
int64_t f_bavail; /* free blocks avail to non-superuser */
|
||||
int64_t f_files; /* total file nodes in file system */
|
||||
int64_t f_ffree; /* free file nodes in fs */
|
||||
uint64_t f_fsid; /* file system id (endian 32 matters) */
|
||||
fsid_t f_fsid; /* file system id */
|
||||
uint32_t f_owner; /* user that mounted the file system */
|
||||
int64_t f_flags; /* copy of mount flags */
|
||||
int64_t f_syncwrites; /* count of sync writes since mount */
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_OPENBSD_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_OPENBSD_H_
|
||||
#include "libc/calls/struct/fsid.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
@ -119,7 +120,7 @@ struct statfs_openbsd {
|
|||
uint64_t f_syncreads; /* count of sync reads since mount */
|
||||
uint64_t f_asyncwrites; /* count of async writes since mount */
|
||||
uint64_t f_asyncreads; /* count of async reads since mount */
|
||||
uint64_t f_fsid; /* file system id (endian 32 matters) */
|
||||
fsid_t f_fsid; /* file system id */
|
||||
uint32_t f_namemax; /* maximum filename length */
|
||||
uint32_t f_owner; /* user that mounted the file system */
|
||||
uint64_t f_ctime; /* last mount [-u] time */
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_XNU_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_XNU_INTERNAL_H_
|
||||
#include "libc/calls/struct/fsid.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
@ -11,7 +12,7 @@ struct statfs_xnu {
|
|||
uint64_t f_bavail; /* free blocks avail to non-superuser */
|
||||
uint64_t f_files; /* total file nodes in file system */
|
||||
uint64_t f_ffree; /* free file nodes in fs */
|
||||
uint64_t f_fsid; /* file system id (endian 32 matters) */
|
||||
fsid_t f_fsid; /* file system id */
|
||||
uint32_t f_owner; /* user that mounted the filesystem */
|
||||
uint32_t f_type; /* type of filesystem */
|
||||
uint32_t f_flags; /* copy of mount exported flags */
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_H_
|
||||
#include "libc/calls/struct/fsid.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
@ -11,7 +12,7 @@ struct statfs { /* cosmo abi */
|
|||
int64_t f_bavail; /* free blocks available to unprivileged users */
|
||||
int64_t f_files; /* total file nodes in filesystem */
|
||||
int64_t f_ffree; /* free file nodes in filesystem */
|
||||
int64_t f_fsid; /* filesystem id */
|
||||
fsid_t f_fsid; /* filesystem id */
|
||||
int64_t f_namelen; /* maximum length of filenames */
|
||||
int64_t f_frsize; /* fragment size */
|
||||
int64_t f_flags; /* mount flags of filesystem 2.6.36 */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_INTERNAL_H_
|
||||
#include "libc/calls/struct/statfs-meta.internal.h"
|
||||
#include "libc/calls/struct/statfs.h"
|
||||
#include "libc/calls/struct/statvfs.h"
|
||||
#include "libc/mem/alloca.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
@ -10,6 +11,7 @@ int sys_statfs(const char *, union statfs_meta *);
|
|||
int sys_fstatfs(int, union statfs_meta *);
|
||||
int sys_fstatfs_nt(int64_t, struct statfs *);
|
||||
int sys_statfs_nt(const char *, struct statfs *);
|
||||
void statfs2statvfs(struct statvfs *, const struct statfs *);
|
||||
|
||||
const char *DescribeStatfs(char[300], int, const struct statfs *);
|
||||
#define DescribeStatfs(rc, sf) DescribeStatfs(alloca(300), rc, sf)
|
||||
|
|
25
libc/calls/struct/statvfs.h
Normal file
25
libc/calls/struct/statvfs.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_STATVFS_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STATVFS_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct statvfs {
|
||||
unsigned long f_bsize; /* Filesystem block size */
|
||||
unsigned long f_frsize; /* Fragment size */
|
||||
uint64_t f_blocks; /* Size of fs in f_frsize units */
|
||||
uint64_t f_bfree; /* Number of free blocks */
|
||||
uint64_t f_bavail; /* Number of free blocks for unprivileged users */
|
||||
uint64_t f_files; /* Number of inodes */
|
||||
uint64_t f_ffree; /* Number of free inodes */
|
||||
uint64_t f_favail; /* Number of free inodes for unprivileged users */
|
||||
unsigned long f_fsid; /* Filesystem ID */
|
||||
unsigned long f_flag; /* Mount flags */
|
||||
unsigned long f_namemax; /* Maximum filename length */
|
||||
};
|
||||
|
||||
int statvfs(const char *, struct statvfs *);
|
||||
int fstatvfs(int, struct statvfs *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_STATVFS_H_ */
|
|
@ -4,7 +4,7 @@
|
|||
#define MAXSYMLINKS 20
|
||||
#define MAXHOSTNAMELEN 64
|
||||
#define MAXNAMLEN 255
|
||||
#define MAXPATHLEN 4096
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#define NBBY 8
|
||||
#define NGROUPS 32
|
||||
#define CANBSIZ 255
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define L_ctermid 20
|
||||
#define FILENAME_MAX PATH_MAX
|
||||
#define FOPEN_MAX 1000
|
||||
#define TMP_MAX 10000
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue