mem.c (026477c1141b67e98e3bd8bdedb7d4b88a3ecd09) | mem.c (91b165c0594ab78c64f26d26e3174e6dfd60ed9d) |
---|---|
1#include <stdio.h> 2#include <stdlib.h> 3#include <stddef.h> 4#include <stdarg.h> 5#include <unistd.h> 6#include <errno.h> 7#include <string.h> 8#include <fcntl.h> --- 100 unchanged lines hidden (view full) --- 109 110 fd = open("/proc/mounts", O_RDONLY); 111 if(fd < 0){ 112 printf("failed to open /proc/mounts, errno = %d\n", errno); 113 return; 114 } 115 116 while(1){ | 1#include <stdio.h> 2#include <stdlib.h> 3#include <stddef.h> 4#include <stdarg.h> 5#include <unistd.h> 6#include <errno.h> 7#include <string.h> 8#include <fcntl.h> --- 100 unchanged lines hidden (view full) --- 109 110 fd = open("/proc/mounts", O_RDONLY); 111 if(fd < 0){ 112 printf("failed to open /proc/mounts, errno = %d\n", errno); 113 return; 114 } 115 116 while(1){ |
117 found = next(fd, buf, sizeof(buf) / sizeof(buf[0]), ' '); | 117 found = next(fd, buf, ARRAY_SIZE(buf), ' '); |
118 if(found != 1) 119 break; 120 121 if(!strncmp(buf, "/dev/shm", strlen("/dev/shm"))) 122 goto found; 123 | 118 if(found != 1) 119 break; 120 121 if(!strncmp(buf, "/dev/shm", strlen("/dev/shm"))) 122 goto found; 123 |
124 found = next(fd, buf, sizeof(buf) / sizeof(buf[0]), '\n'); | 124 found = next(fd, buf, ARRAY_SIZE(buf), '\n'); |
125 if(found != 1) 126 break; 127 } 128 129err: 130 if(found == 0) 131 printf("nothing mounted on /dev/shm\n"); 132 else if(found < 0) 133 printf("read returned errno %d\n", -found); 134 135 return; 136 137found: | 125 if(found != 1) 126 break; 127 } 128 129err: 130 if(found == 0) 131 printf("nothing mounted on /dev/shm\n"); 132 else if(found < 0) 133 printf("read returned errno %d\n", -found); 134 135 return; 136 137found: |
138 found = next(fd, buf, sizeof(buf) / sizeof(buf[0]), ' '); | 138 found = next(fd, buf, ARRAY_SIZE(buf), ' '); |
139 if(found != 1) 140 goto err; 141 142 if(strncmp(buf, "tmpfs", strlen("tmpfs"))){ 143 printf("not tmpfs\n"); 144 return; 145 } 146 --- 122 unchanged lines hidden --- | 139 if(found != 1) 140 goto err; 141 142 if(strncmp(buf, "tmpfs", strlen("tmpfs"))){ 143 printf("not tmpfs\n"); 144 return; 145 } 146 --- 122 unchanged lines hidden --- |