fd 334 kernel/proc.c for (int fd = 0; fd < NOFILE; fd++) { fd 335 kernel/proc.c if (p->ofile[fd]) { fd 336 kernel/proc.c struct file *f = p->ofile[fd]; fd 338 kernel/proc.c p->ofile[fd] = 0; fd 24 kernel/sysfile.c int fd; fd 27 kernel/sysfile.c argint(n, &fd); fd 28 kernel/sysfile.c if (fd < 0 || fd >= NOFILE || (f = myproc()->ofile[fd]) == 0) fd 31 kernel/sysfile.c *pfd = fd; fd 42 kernel/sysfile.c int fd; fd 45 kernel/sysfile.c for (fd = 0; fd < NOFILE; fd++) { fd 46 kernel/sysfile.c if (p->ofile[fd] == 0) { fd 47 kernel/sysfile.c p->ofile[fd] = f; fd 48 kernel/sysfile.c return fd; fd 58 kernel/sysfile.c int fd; fd 62 kernel/sysfile.c if ((fd = fdalloc(f)) < 0) fd 65 kernel/sysfile.c return fd; fd 100 kernel/sysfile.c int fd; fd 103 kernel/sysfile.c if (argfd(0, &fd, &f) < 0) fd 105 kernel/sysfile.c myproc()->ofile[fd] = 0; fd 332 kernel/sysfile.c int fd, omode; fd 368 kernel/sysfile.c if ((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0) { fd 394 kernel/sysfile.c return fd; fd 75 mkfs/mkfs.c int i, cc, fd; fd 144 mkfs/mkfs.c if ((fd = open(argv[i], 0)) < 0) fd 163 mkfs/mkfs.c while ((cc = read(fd, buf, sizeof(buf))) > 0) fd 166 mkfs/mkfs.c close(fd); fd 8 user/cat.c cat(int fd) fd 12 user/cat.c while ((n = read(fd, buf, sizeof(buf))) > 0) { fd 27 user/cat.c int fd, i; fd 35 user/cat.c if ((fd = open(argv[i], O_RDONLY)) < 0) { fd 39 user/cat.c cat(fd); fd 40 user/cat.c close(fd); fd 15 user/forphan.c int fd = 0; fd 20 user/forphan.c if ((fd = open(ff, O_CREATE | O_WRONLY)) < 0) { fd 24 user/forphan.c if (fstat(fd, &st) < 0) { fd 12 user/grep.c grep(char *pattern, int fd) fd 18 user/grep.c while ((n = read(fd, buf + m, sizeof(buf) - m - 1)) > 0) { fd 40 user/grep.c int fd, i; fd 55 user/grep.c if ((fd = open(argv[i], O_RDONLY)) < 0) { fd 59 user/grep.c grep(pattern, fd); fd 60 user/grep.c close(fd); fd 53 user/grind.c int fd = -1; fd 84 user/grind.c close(fd); fd 85 user/grind.c fd = open("/grindir/../a", O_CREATE | O_RDWR); fd 87 user/grind.c close(fd); fd 88 user/grind.c fd = open("/./grindir/./../b", O_CREATE | O_RDWR); fd 90 user/grind.c write(fd, buf, sizeof(buf)); fd 92 user/grind.c read(fd, buf, sizeof(buf)); fd 187 user/grind.c fd = open("x", O_CREATE | O_RDWR); fd 16 user/logstress.c int fd, n; fd 26 user/logstress.c fd = open(argv[i], O_CREATE | O_RDWR); fd 27 user/logstress.c if (fd < 0) { fd 33 user/logstress.c if ((n = write(fd, buf, SZ)) != SZ) { fd 31 user/ls.c int fd; fd 35 user/ls.c if ((fd = open(path, O_RDONLY)) < 0) { fd 40 user/ls.c if (fstat(fd, &st) < 0) { fd 42 user/ls.c close(fd); fd 60 user/ls.c while (read(fd, &de, sizeof(de)) == sizeof(de)) { fd 73 user/ls.c close(fd); fd 10 user/printf.c putc(int fd, char c) fd 12 user/printf.c write(fd, &c, 1); fd 16 user/printf.c printint(int fd, long long xx, int base, int sgn) fd 38 user/printf.c putc(fd, buf[i]); fd 42 user/printf.c printptr(int fd, uint64 x) fd 45 user/printf.c putc(fd, '0'); fd 46 user/printf.c putc(fd, 'x'); fd 48 user/printf.c putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); fd 53 user/printf.c vprintf(int fd, const char *fmt, va_list ap) fd 65 user/printf.c putc(fd, c0); fd 74 user/printf.c printint(fd, va_arg(ap, int), 10, 1); fd 76 user/printf.c printint(fd, va_arg(ap, uint64), 10, 1); fd 79 user/printf.c printint(fd, va_arg(ap, uint64), 10, 1); fd 82 user/printf.c printint(fd, va_arg(ap, uint32), 10, 0); fd 84 user/printf.c printint(fd, va_arg(ap, uint64), 10, 0); fd 87 user/printf.c printint(fd, va_arg(ap, uint64), 10, 0); fd 90 user/printf.c printint(fd, va_arg(ap, uint32), 16, 0); fd 92 user/printf.c printint(fd, va_arg(ap, uint64), 16, 0); fd 95 user/printf.c printint(fd, va_arg(ap, uint64), 16, 0); fd 98 user/printf.c printptr(fd, va_arg(ap, uint64)); fd 100 user/printf.c putc(fd, va_arg(ap, uint32)); fd 105 user/printf.c putc(fd, *s); fd 107 user/printf.c putc(fd, '%'); fd 110 user/printf.c putc(fd, '%'); fd 111 user/printf.c putc(fd, c0); fd 120 user/printf.c fprintf(int fd, const char *fmt, ...) fd 125 user/printf.c vprintf(fd, fmt, ap); fd 32 user/sh.c int fd; fd 85 user/sh.c close(rcmd->fd); fd 149 user/sh.c int fd; fd 152 user/sh.c while ((fd = open("console", O_RDWR)) >= 0) { fd 153 user/sh.c if (fd >= 3) { fd 154 user/sh.c close(fd); fd 213 user/sh.c redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd) fd 224 user/sh.c cmd->fd = fd; fd 19 user/stressfs.c int fd, i; fd 33 user/stressfs.c fd = open(path, O_CREATE | O_RDWR); fd 36 user/stressfs.c write(fd, data, sizeof(data)); fd 38 user/stressfs.c close(fd); fd 42 user/stressfs.c fd = open(path, O_RDONLY); fd 44 user/stressfs.c read(fd, data, sizeof(data)); fd 45 user/stressfs.c close(fd); fd 90 user/ulib.c int fd; fd 93 user/ulib.c fd = open(n, O_RDONLY); fd 94 user/ulib.c if (fd < 0) fd 96 user/ulib.c r = fstat(fd, st); fd 97 user/ulib.c close(fd); fd 18 user/user.h int fstat(int fd, struct stat *); fd 41 user/usertests.c int fd = open("copyin1", O_CREATE | O_WRONLY); fd 42 user/usertests.c if (fd < 0) { fd 46 user/usertests.c int n = write(fd, (void *)addr, 8192); fd 51 user/usertests.c close(fd); fd 87 user/usertests.c int fd = open("README", 0); fd 88 user/usertests.c if (fd < 0) { fd 92 user/usertests.c int n = read(fd, (void *)addr, 8192); fd 97 user/usertests.c close(fd); fd 130 user/usertests.c int fd = open((char *)addr, O_CREATE | O_WRONLY); fd 131 user/usertests.c if (fd >= 0) { fd 132 user/usertests.c printf("open(%p) returned %d, not -1\n", (void *)addr, fd); fd 156 user/usertests.c int fd = open(b, O_CREATE | O_WRONLY); fd 157 user/usertests.c if (fd != -1) { fd 158 user/usertests.c printf("open(%s) returned %d, not -1\n", b, fd); fd 171 user/usertests.c printf("exec(%s) returned %d, not -1\n", b, fd); fd 188 user/usertests.c printf("exec(echo, BIG) returned %d, not -1\n", fd); fd 226 user/usertests.c int fd = open(b, O_CREATE | O_WRONLY); fd 227 user/usertests.c if (fd != -1) { fd 228 user/usertests.c printf("open(%s) returned %d, not -1\n", b, fd); fd 241 user/usertests.c printf("exec(%s) returned %d, not -1\n", b, fd); fd 251 user/usertests.c int fd, n; fd 265 user/usertests.c fd = open("rwsbrk", O_CREATE | O_WRONLY); fd 266 user/usertests.c if (fd < 0) { fd 270 user/usertests.c n = write(fd, (void *)(a + PGSIZE), 1024); fd 275 user/usertests.c close(fd); fd 278 user/usertests.c fd = open("README", O_RDONLY); fd 279 user/usertests.c if (fd < 0) { fd 283 user/usertests.c n = read(fd, (void *)(a + PGSIZE), 10); fd 288 user/usertests.c close(fd); fd 390 user/usertests.c int fd = open("truncfile", O_WRONLY); fd 391 user/usertests.c if (fd < 0) { fd 395 user/usertests.c int n = write(fd, "1234567890", 10); fd 400 user/usertests.c close(fd); fd 401 user/usertests.c fd = open("truncfile", O_RDONLY); fd 402 user/usertests.c read(fd, buf, sizeof(buf)); fd 403 user/usertests.c close(fd); fd 409 user/usertests.c int fd = open("truncfile", O_CREATE | O_WRONLY | O_TRUNC); fd 410 user/usertests.c if (fd < 0) { fd 414 user/usertests.c int n = write(fd, "xxx", 3); fd 419 user/usertests.c close(fd); fd 505 user/usertests.c int fd = open("oidir", O_RDWR); fd 506 user/usertests.c if (fd >= 0) { fd 526 user/usertests.c int fd; fd 528 user/usertests.c fd = open("echo", 0); fd 529 user/usertests.c if (fd < 0) { fd 533 user/usertests.c close(fd); fd 534 user/usertests.c fd = open("doesnotexist", 0); fd 535 user/usertests.c if (fd >= 0) { fd 544 user/usertests.c int fd; fd 548 user/usertests.c fd = open("small", O_CREATE | O_RDWR); fd 549 user/usertests.c if (fd < 0) { fd 554 user/usertests.c if (write(fd, "aaaaaaaaaa", SZ) != SZ) { fd 558 user/usertests.c if (write(fd, "bbbbbbbbbb", SZ) != SZ) { fd 563 user/usertests.c close(fd); fd 564 user/usertests.c fd = open("small", O_RDONLY); fd 565 user/usertests.c if (fd < 0) { fd 569 user/usertests.c i = read(fd, buf, N * SZ * 2); fd 574 user/usertests.c close(fd); fd 585 user/usertests.c int i, fd, n; fd 587 user/usertests.c fd = open("big", O_CREATE | O_RDWR); fd 588 user/usertests.c if (fd < 0) { fd 595 user/usertests.c if (write(fd, buf, BSIZE) != BSIZE) { fd 601 user/usertests.c close(fd); fd 603 user/usertests.c fd = open("big", O_RDONLY); fd 604 user/usertests.c if (fd < 0) { fd 611 user/usertests.c i = read(fd, buf, BSIZE); fd 628 user/usertests.c close(fd); fd 639 user/usertests.c int i, fd; fd 647 user/usertests.c fd = open(name, O_CREATE | O_RDWR); fd 648 user/usertests.c close(fd); fd 685 user/usertests.c int fd, xstatus, pid; fd 702 user/usertests.c fd = open("echo-ok", O_CREATE | O_WRONLY); fd 703 user/usertests.c if (fd < 0) { fd 707 user/usertests.c if (fd != 1) { fd 725 user/usertests.c fd = open("echo-ok", O_RDONLY); fd 726 user/usertests.c if (fd < 0) { fd 730 user/usertests.c if (read(fd, buf, 2) != 2) { fd 1045 user/usertests.c int fd = open("stopforking", 0); fd 1046 user/usertests.c if (fd >= 0) { fd 1132 user/usertests.c int fd, pid, i, n, nc, np; fd 1137 user/usertests.c fd = open("sharedfd", O_CREATE | O_RDWR); fd 1138 user/usertests.c if (fd < 0) { fd 1145 user/usertests.c if (write(fd, buf, sizeof(buf)) != sizeof(buf)) { fd 1159 user/usertests.c close(fd); fd 1160 user/usertests.c fd = open("sharedfd", 0); fd 1161 user/usertests.c if (fd < 0) { fd 1166 user/usertests.c while ((n = read(fd, buf, sizeof(buf))) > 0) { fd 1174 user/usertests.c close(fd); fd 1189 user/usertests.c int fd, pid, i, j, n, total, pi; fd 1205 user/usertests.c fd = open(fname, O_CREATE | O_RDWR); fd 1206 user/usertests.c if (fd < 0) { fd 1213 user/usertests.c if ((n = write(fd, buf, SZ)) != SZ) { fd 1231 user/usertests.c fd = open(fname, 0); fd 1233 user/usertests.c while ((n = read(fd, buf, sizeof(buf))) > 0) { fd 1242 user/usertests.c close(fd); fd 1256 user/usertests.c int pid, i, fd, pi; fd 1271 user/usertests.c fd = open(name, O_CREATE | O_RDWR); fd 1272 user/usertests.c if (fd < 0) { fd 1276 user/usertests.c close(fd); fd 1301 user/usertests.c fd = open(name, 0); fd 1302 user/usertests.c if ((i == 0 || i >= N / 2) && fd < 0) { fd 1305 user/usertests.c } else if ((i >= 1 && i < N / 2) && fd >= 0) { fd 1309 user/usertests.c if (fd >= 0) fd 1310 user/usertests.c close(fd); fd 1328 user/usertests.c int fd, fd1; fd 1330 user/usertests.c fd = open("unlinkread", O_CREATE | O_RDWR); fd 1331 user/usertests.c if (fd < 0) { fd 1335 user/usertests.c write(fd, "hello", SZ); fd 1336 user/usertests.c close(fd); fd 1338 user/usertests.c fd = open("unlinkread", O_RDWR); fd 1339 user/usertests.c if (fd < 0) { fd 1352 user/usertests.c if (read(fd, buf, sizeof(buf)) != SZ) { fd 1360 user/usertests.c if (write(fd, buf, 10) != 10) { fd 1364 user/usertests.c close(fd); fd 1372 user/usertests.c int fd; fd 1377 user/usertests.c fd = open("lf1", O_CREATE | O_RDWR); fd 1378 user/usertests.c if (fd < 0) { fd 1382 user/usertests.c if (write(fd, "hello", SZ) != SZ) { fd 1386 user/usertests.c close(fd); fd 1399 user/usertests.c fd = open("lf2", 0); fd 1400 user/usertests.c if (fd < 0) { fd 1404 user/usertests.c if (read(fd, buf, sizeof(buf)) != SZ) { fd 1408 user/usertests.c close(fd); fd 1433 user/usertests.c int i, pid, n, fd; fd 1451 user/usertests.c fd = open(file, O_CREATE | O_RDWR); fd 1452 user/usertests.c if (fd < 0) { fd 1456 user/usertests.c close(fd); fd 1469 user/usertests.c fd = open(".", 0); fd 1471 user/usertests.c while (read(fd, &de, sizeof(de)) > 0) { fd 1488 user/usertests.c close(fd); fd 1559 user/usertests.c int fd, cc; fd 1567 user/usertests.c fd = open("dd/ff", O_CREATE | O_RDWR); fd 1568 user/usertests.c if (fd < 0) { fd 1572 user/usertests.c write(fd, "ff", 2); fd 1573 user/usertests.c close(fd); fd 1585 user/usertests.c fd = open("dd/dd/ff", O_CREATE | O_RDWR); fd 1586 user/usertests.c if (fd < 0) { fd 1590 user/usertests.c write(fd, "FF", 2); fd 1591 user/usertests.c close(fd); fd 1593 user/usertests.c fd = open("dd/dd/../ff", 0); fd 1594 user/usertests.c if (fd < 0) { fd 1598 user/usertests.c cc = read(fd, buf, sizeof(buf)); fd 1603 user/usertests.c close(fd); fd 1636 user/usertests.c fd = open("dd/dd/ffff", 0); fd 1637 user/usertests.c if (fd < 0) { fd 1641 user/usertests.c if (read(fd, buf, sizeof(buf)) != 2) { fd 1645 user/usertests.c close(fd); fd 1739 user/usertests.c int fd, sz; fd 1743 user/usertests.c fd = open("bigwrite", O_CREATE | O_RDWR); fd 1744 user/usertests.c if (fd < 0) { fd 1750 user/usertests.c int cc = write(fd, buf, sz); fd 1756 user/usertests.c close(fd); fd 1765 user/usertests.c int fd, i, total, cc; fd 1768 user/usertests.c fd = open("bigfile.dat", O_CREATE | O_RDWR); fd 1769 user/usertests.c if (fd < 0) { fd 1775 user/usertests.c if (write(fd, buf, SZ) != SZ) { fd 1780 user/usertests.c close(fd); fd 1782 user/usertests.c fd = open("bigfile.dat", 0); fd 1783 user/usertests.c if (fd < 0) { fd 1789 user/usertests.c cc = read(fd, buf, SZ / 2); fd 1806 user/usertests.c close(fd); fd 1817 user/usertests.c int fd; fd 1829 user/usertests.c fd = open("123456789012345/123456789012345/123456789012345", O_CREATE); fd 1830 user/usertests.c if (fd < 0) { fd 1835 user/usertests.c close(fd); fd 1836 user/usertests.c fd = open("12345678901234/12345678901234/12345678901234", 0); fd 1837 user/usertests.c if (fd < 0) { fd 1841 user/usertests.c close(fd); fd 1901 user/usertests.c int fd; fd 1903 user/usertests.c fd = open("dirfile", O_CREATE); fd 1904 user/usertests.c if (fd < 0) { fd 1908 user/usertests.c close(fd); fd 1913 user/usertests.c fd = open("dirfile/xx", 0); fd 1914 user/usertests.c if (fd >= 0) { fd 1918 user/usertests.c fd = open("dirfile/xx", O_CREATE); fd 1919 user/usertests.c if (fd >= 0) { fd 1940 user/usertests.c fd = open(".", O_RDWR); fd 1941 user/usertests.c if (fd >= 0) { fd 1945 user/usertests.c fd = open(".", 0); fd 1946 user/usertests.c if (write(fd, "x", 1) > 0) { fd 1950 user/usertests.c close(fd); fd 1958 user/usertests.c int i, fd; fd 1972 user/usertests.c fd = open("", O_CREATE); fd 1973 user/usertests.c if (fd >= 0) fd 1974 user/usertests.c close(fd); fd 1975 user/usertests.c fd = open("xx", O_CREATE); fd 1976 user/usertests.c if (fd >= 0) fd 1977 user/usertests.c close(fd); fd 2278 user/usertests.c int fd, n; fd 2281 user/usertests.c fd = open("sbrk", O_CREATE | O_WRONLY); fd 2283 user/usertests.c if (fd < 0) { fd 2287 user/usertests.c if ((n = write(fd, a, PGSIZE)) < 0) { fd 2291 user/usertests.c close(fd); fd 2338 user/usertests.c int pid, fd, xstatus; fd 2354 user/usertests.c fd = open("bigarg-ok", O_CREATE); fd 2355 user/usertests.c close(fd); fd 2365 user/usertests.c fd = open("bigarg-ok", 0); fd 2366 user/usertests.c if (fd < 0) { fd 2370 user/usertests.c close(fd); fd 2392 user/usertests.c int fd = open(name, O_CREATE | O_RDWR); fd 2393 user/usertests.c if (fd < 0) { fd 2399 user/usertests.c int cc = write(fd, buf, BSIZE); fd 2406 user/usertests.c close(fd); fd 2429 user/usertests.c int fd; fd 2430 user/usertests.c fd = open("init", O_RDONLY); fd 2431 user/usertests.c if (fd < 0) { fd 2435 user/usertests.c read(fd, sbrk(0) - 1, -1); fd 2436 user/usertests.c close(fd); fd 2588 user/usertests.c int fd = open(p, O_RDWR | O_CREATE); fd 2589 user/usertests.c write(fd, p, 1); fd 2590 user/usertests.c close(fd); fd 2591 user/usertests.c fd = open(p, O_RDWR); fd 2593 user/usertests.c read(fd, p, 1); fd 2718 user/usertests.c int fd = open("README", 0); fd 2719 user/usertests.c if (fd < 0) { fd 2723 user/usertests.c if (read(fd, (char *)bad[i], 512) >= 0) { fd 2727 user/usertests.c close(fd); fd 2728 user/usertests.c fd = open("junk", O_CREATE | O_RDWR | O_TRUNC); fd 2729 user/usertests.c if (fd < 0) { fd 2733 user/usertests.c if (write(fd, (char *)bad[i], 512) >= 0) { fd 2737 user/usertests.c close(fd); fd 2757 user/usertests.c int fd = open(&p[4095], O_RDONLY); fd 2758 user/usertests.c if (fd < 0) { fd 2764 user/usertests.c int r = fstat(fd, &st); fd 2775 user/usertests.c close(fd); fd 2839 user/usertests.c int fd = open("testfile", O_CREATE | O_RDWR); fd 2840 user/usertests.c if (fd < 0) { fd 2845 user/usertests.c int cc = write(fd, "A", 1); fd 2851 user/usertests.c close(fd); fd 2852 user/usertests.c fd = open("testfile", O_RDWR); fd 2853 user/usertests.c if (fd < 0) { fd 2869 user/usertests.c cc = write(fd, p - 1, 2); fd 2875 user/usertests.c close(fd); fd 2877 user/usertests.c fd = open("testfile", O_RDONLY); fd 2878 user/usertests.c if (fd < 0) { fd 2884 user/usertests.c cc = read(fd, &b, 1); fd 2890 user/usertests.c close(fd); fd 2897 user/usertests.c fd = open("bigfile", O_CREATE | O_RDWR); fd 2901 user/usertests.c cc = write(fd, buf, sizeof(buf)); fd 2907 user/usertests.c close(fd); fd 2911 user/usertests.c fd = open("testfile", O_RDONLY); fd 2912 user/usertests.c if (fd < 0) { fd 2917 user/usertests.c cc = read(fd, &b, 1); fd 2923 user/usertests.c close(fd); fd 3048 user/usertests.c int i, fd; fd 3053 user/usertests.c fd = open("bd", O_CREATE); fd 3054 user/usertests.c if (fd < 0) { fd 3058 user/usertests.c close(fd); fd 3108 user/usertests.c int fd = open(name, O_CREATE | O_RDWR); fd 3109 user/usertests.c if (fd < 0) { fd 3114 user/usertests.c int cc = write(fd, buf, sz); fd 3119 user/usertests.c close(fd); fd 3150 user/usertests.c int fd = open("junk", O_CREATE | O_WRONLY); fd 3151 user/usertests.c if (fd < 0) { fd 3155 user/usertests.c write(fd, (char *)0xffffffffffL, 1); fd 3156 user/usertests.c close(fd); fd 3160 user/usertests.c int fd = open("junk", O_CREATE | O_WRONLY); fd 3161 user/usertests.c if (fd < 0) { fd 3165 user/usertests.c if (write(fd, "x", 1) != 1) { fd 3169 user/usertests.c close(fd); fd 3229 user/usertests.c int fd = open(name, O_CREATE | O_RDWR | O_TRUNC); fd 3230 user/usertests.c if (fd < 0) { fd 3238 user/usertests.c if (write(fd, buf, BSIZE) != BSIZE) { fd 3240 user/usertests.c close(fd); fd 3244 user/usertests.c close(fd); fd 3260 user/usertests.c int fd = open(name, O_CREATE | O_RDWR | O_TRUNC); fd 3261 user/usertests.c if (fd < 0) fd 3263 user/usertests.c close(fd); fd 3305 user/usertests.c int fd = open(name, O_CREATE | O_RDWR | O_TRUNC); fd 3306 user/usertests.c if (fd < 0) { fd 3310 user/usertests.c close(fd); fd 3333 user/usertests.c int fd = open("/lof", O_CREATE | O_RDWR); fd 3334 user/usertests.c if (fd < 0) { fd 3338 user/usertests.c close(fd); fd 9 user/wc.c wc(int fd, char *name) fd 16 user/wc.c while ((n = read(fd, buf, sizeof(buf))) > 0) { fd 39 user/wc.c int fd, i; fd 47 user/wc.c if ((fd = open(argv[i], O_RDONLY)) < 0) { fd 51 user/wc.c wc(fd, argv[i]); fd 52 user/wc.c close(fd);