summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]libc/bionic/cpuacct.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libc/bionic/cpuacct.c b/libc/bionic/cpuacct.c
index 7317073..1d12308 100644..100755
--- a/libc/bionic/cpuacct.c
+++ b/libc/bionic/cpuacct.c
@@ -29,17 +29,18 @@
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
+#include <fcntl.h>
#include "cpuacct.h"
int cpuacct_add(uid_t uid)
{
int count;
- FILE *fp;
+ int fd;
char buf[80];
count = snprintf(buf, sizeof(buf), "/acct/uid/%d/tasks", uid);
- fp = fopen(buf, "w+");
- if (!fp) {
+ fd = open(buf, O_RDWR| O_SYNC);
+ if (fd < 0) {
/* Note: sizeof("tasks") returns 6, which includes the NULL char */
buf[count - sizeof("tasks")] = 0;
if (mkdir(buf, 0775) < 0)
@@ -47,13 +48,13 @@ int cpuacct_add(uid_t uid)
/* Note: sizeof("tasks") returns 6, which includes the NULL char */
buf[count - sizeof("tasks")] = '/';
- fp = fopen(buf, "w+");
+ fd = open(buf, O_RDWR| O_SYNC);
}
- if (!fp)
+ if (fd < 0)
return -errno;
- fprintf(fp, "0");
- if (fclose(fp))
+ write(fd, "0", 2);
+ if (close(fd))
return -errno;
return 0;