Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: fusl/src/stat/statvfs.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <sys/statvfs.h> 1 #include <sys/statvfs.h>
2 #include <sys/statfs.h> 2 #include <sys/statfs.h>
3 #include "syscall.h" 3 #include "syscall.h"
4 #include "libc.h" 4 #include "libc.h"
5 5
6 int __statfs(const char *path, struct statfs *buf) 6 int __statfs(const char* path, struct statfs* buf) {
7 { 7 *buf = (struct statfs){0};
8 » *buf = (struct statfs){0};
9 #ifdef SYS_statfs64 8 #ifdef SYS_statfs64
10 » return syscall(SYS_statfs64, path, sizeof *buf, buf); 9 return syscall(SYS_statfs64, path, sizeof *buf, buf);
11 #else 10 #else
12 » return syscall(SYS_statfs, path, buf); 11 return syscall(SYS_statfs, path, buf);
13 #endif 12 #endif
14 } 13 }
15 14
16 int __fstatfs(int fd, struct statfs *buf) 15 int __fstatfs(int fd, struct statfs* buf) {
17 { 16 *buf = (struct statfs){0};
18 » *buf = (struct statfs){0};
19 #ifdef SYS_fstatfs64 17 #ifdef SYS_fstatfs64
20 » return syscall(SYS_fstatfs64, fd, sizeof *buf, buf); 18 return syscall(SYS_fstatfs64, fd, sizeof *buf, buf);
21 #else 19 #else
22 » return syscall(SYS_fstatfs, fd, buf); 20 return syscall(SYS_fstatfs, fd, buf);
23 #endif 21 #endif
24 } 22 }
25 23
26 weak_alias(__statfs, statfs); 24 weak_alias(__statfs, statfs);
27 weak_alias(__fstatfs, fstatfs); 25 weak_alias(__fstatfs, fstatfs);
28 26
29 static void fixup(struct statvfs *out, const struct statfs *in) 27 static void fixup(struct statvfs* out, const struct statfs* in) {
30 { 28 *out = (struct statvfs){0};
31 » *out = (struct statvfs){0}; 29 out->f_bsize = in->f_bsize;
32 » out->f_bsize = in->f_bsize; 30 out->f_frsize = in->f_frsize ? in->f_frsize : in->f_bsize;
33 » out->f_frsize = in->f_frsize ? in->f_frsize : in->f_bsize; 31 out->f_blocks = in->f_blocks;
34 » out->f_blocks = in->f_blocks; 32 out->f_bfree = in->f_bfree;
35 » out->f_bfree = in->f_bfree; 33 out->f_bavail = in->f_bavail;
36 » out->f_bavail = in->f_bavail; 34 out->f_files = in->f_files;
37 » out->f_files = in->f_files; 35 out->f_ffree = in->f_ffree;
38 » out->f_ffree = in->f_ffree; 36 out->f_favail = in->f_ffree;
39 » out->f_favail = in->f_ffree; 37 out->f_fsid = in->f_fsid.__val[0];
40 » out->f_fsid = in->f_fsid.__val[0]; 38 out->f_flag = in->f_flags;
41 » out->f_flag = in->f_flags; 39 out->f_namemax = in->f_namelen;
42 » out->f_namemax = in->f_namelen;
43 } 40 }
44 41
45 int statvfs(const char *restrict path, struct statvfs *restrict buf) 42 int statvfs(const char* restrict path, struct statvfs* restrict buf) {
46 { 43 struct statfs kbuf;
47 » struct statfs kbuf; 44 if (__statfs(path, &kbuf) < 0)
48 » if (__statfs(path, &kbuf)<0) return -1; 45 return -1;
49 » fixup(buf, &kbuf); 46 fixup(buf, &kbuf);
50 » return 0; 47 return 0;
51 } 48 }
52 49
53 int fstatvfs(int fd, struct statvfs *buf) 50 int fstatvfs(int fd, struct statvfs* buf) {
54 { 51 struct statfs kbuf;
55 » struct statfs kbuf; 52 if (__fstatfs(fd, &kbuf) < 0)
56 » if (__fstatfs(fd, &kbuf)<0) return -1; 53 return -1;
57 » fixup(buf, &kbuf); 54 fixup(buf, &kbuf);
58 » return 0; 55 return 0;
59 } 56 }
60 57
61 LFS64(statvfs); 58 LFS64(statvfs);
62 weak_alias(__statfs, statfs64); 59 weak_alias(__statfs, statfs64);
63 LFS64(fstatvfs); 60 LFS64(fstatvfs);
64 weak_alias(__fstatfs, fstatfs64); 61 weak_alias(__fstatfs, fstatfs64);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698