fd 355 kernel/proc.c for(int fd = 0; fd < NOFILE; fd++){ fd 356 kernel/proc.c if(p->ofile[fd]){ fd 357 kernel/proc.c struct file *f = p->ofile[fd]; fd 359 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 308 kernel/sysfile.c int fd, omode; fd 344 kernel/sysfile.c if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ fd 370 kernel/sysfile.c return fd; fd 71 mkfs/mkfs.c int i, cc, fd; fd 140 mkfs/mkfs.c if((fd = open(argv[i], 0)) < 0) fd 157 mkfs/mkfs.c while((cc = read(fd, buf, sizeof(buf))) > 0) fd 160 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], 0)) < 0){ fd 39 user/cat.c cat(fd); fd 40 user/cat.c close(fd); fd 11 user/grep.c grep(char *pattern, int fd) fd 17 user/grep.c while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){ fd 39 user/grep.c int fd, i; fd 54 user/grep.c if((fd = open(argv[i], 0)) < 0){ fd 58 user/grep.c grep(pattern, fd); fd 59 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 29 user/ls.c int fd; fd 33 user/ls.c if((fd = open(path, 0)) < 0){ fd 38 user/ls.c if(fstat(fd, &st) < 0){ fd 40 user/ls.c close(fd); fd 58 user/ls.c while(read(fd, &de, sizeof(de)) == sizeof(de)){ fd 71 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, int 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 44 user/printf.c putc(fd, '0'); fd 45 user/printf.c putc(fd, 'x'); fd 47 user/printf.c putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); fd 52 user/printf.c vprintf(int fd, const char *fmt, va_list ap) fd 64 user/printf.c putc(fd, c); fd 68 user/printf.c printint(fd, va_arg(ap, int), 10, 1); fd 70 user/printf.c printint(fd, va_arg(ap, uint64), 10, 0); fd 72 user/printf.c printint(fd, va_arg(ap, int), 16, 0); fd 74 user/printf.c printptr(fd, va_arg(ap, uint64)); fd 80 user/printf.c putc(fd, *s); fd 84 user/printf.c putc(fd, va_arg(ap, uint)); fd 86 user/printf.c putc(fd, c); fd 89 user/printf.c putc(fd, '%'); fd 90 user/printf.c putc(fd, c); fd 98 user/printf.c fprintf(int fd, const char *fmt, ...) fd 103 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 208 user/sh.c redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd) fd 219 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 37 user/stressfs.c close(fd); fd 41 user/stressfs.c fd = open(path, O_RDONLY); fd 43 user/stressfs.c read(fd, data, sizeof(data)); fd 44 user/stressfs.c close(fd); fd 87 user/ulib.c int fd; fd 90 user/ulib.c fd = open(n, O_RDONLY); fd 91 user/ulib.c if(fd < 0) fd 93 user/ulib.c r = fstat(fd, st); fd 94 user/ulib.c close(fd); fd 16 user/user.h int fstat(int fd, struct stat*); fd 40 user/usertests.c int fd = open("copyin1", O_CREATE|O_WRONLY); fd 41 user/usertests.c if(fd < 0){ fd 45 user/usertests.c int n = write(fd, (void*)addr, 8192); fd 50 user/usertests.c close(fd); fd 84 user/usertests.c int fd = open("README", 0); fd 85 user/usertests.c if(fd < 0){ fd 89 user/usertests.c int n = read(fd, (void*)addr, 8192); fd 94 user/usertests.c close(fd); fd 125 user/usertests.c int fd = open((char *)addr, O_CREATE|O_WRONLY); fd 126 user/usertests.c if(fd >= 0){ fd 127 user/usertests.c printf("open(%p) returned %d, not -1\n", addr, fd); fd 151 user/usertests.c int fd = open(b, O_CREATE | O_WRONLY); fd 152 user/usertests.c if(fd != -1){ fd 153 user/usertests.c printf("open(%s) returned %d, not -1\n", b, fd); fd 166 user/usertests.c printf("exec(%s) returned %d, not -1\n", b, fd); fd 183 user/usertests.c printf("exec(echo, BIG) returned %d, not -1\n", fd); fd 221 user/usertests.c int fd = open(b, O_CREATE | O_WRONLY); fd 222 user/usertests.c if(fd != -1){ fd 223 user/usertests.c printf("open(%s) returned %d, not -1\n", b, fd); fd 236 user/usertests.c printf("exec(%s) returned %d, not -1\n", b, fd); fd 246 user/usertests.c int fd, n; fd 260 user/usertests.c fd = open("rwsbrk", O_CREATE|O_WRONLY); fd 261 user/usertests.c if(fd < 0){ fd 265 user/usertests.c n = write(fd, (void*)(a+4096), 1024); fd 270 user/usertests.c close(fd); fd 273 user/usertests.c fd = open("README", O_RDONLY); fd 274 user/usertests.c if(fd < 0){ fd 278 user/usertests.c n = read(fd, (void*)(a+4096), 10); fd 283 user/usertests.c close(fd); fd 385 user/usertests.c int fd = open("truncfile", O_WRONLY); fd 386 user/usertests.c if(fd < 0){ fd 390 user/usertests.c int n = write(fd, "1234567890", 10); fd 395 user/usertests.c close(fd); fd 396 user/usertests.c fd = open("truncfile", O_RDONLY); fd 397 user/usertests.c read(fd, buf, sizeof(buf)); fd 398 user/usertests.c close(fd); fd 404 user/usertests.c int fd = open("truncfile", O_CREATE|O_WRONLY|O_TRUNC); fd 405 user/usertests.c if(fd < 0){ fd 409 user/usertests.c int n = write(fd, "xxx", 3); fd 414 user/usertests.c close(fd); fd 501 user/usertests.c int fd = open("oidir", O_RDWR); fd 502 user/usertests.c if(fd >= 0){ fd 522 user/usertests.c int fd; fd 524 user/usertests.c fd = open("echo", 0); fd 525 user/usertests.c if(fd < 0){ fd 529 user/usertests.c close(fd); fd 530 user/usertests.c fd = open("doesnotexist", 0); fd 531 user/usertests.c if(fd >= 0){ fd 540 user/usertests.c int fd; fd 544 user/usertests.c fd = open("small", O_CREATE|O_RDWR); fd 545 user/usertests.c if(fd < 0){ fd 550 user/usertests.c if(write(fd, "aaaaaaaaaa", SZ) != SZ){ fd 554 user/usertests.c if(write(fd, "bbbbbbbbbb", SZ) != SZ){ fd 559 user/usertests.c close(fd); fd 560 user/usertests.c fd = open("small", O_RDONLY); fd 561 user/usertests.c if(fd < 0){ fd 565 user/usertests.c i = read(fd, buf, N*SZ*2); fd 570 user/usertests.c close(fd); fd 581 user/usertests.c int i, fd, n; fd 583 user/usertests.c fd = open("big", O_CREATE|O_RDWR); fd 584 user/usertests.c if(fd < 0){ fd 591 user/usertests.c if(write(fd, buf, BSIZE) != BSIZE){ fd 597 user/usertests.c close(fd); fd 599 user/usertests.c fd = open("big", O_RDONLY); fd 600 user/usertests.c if(fd < 0){ fd 607 user/usertests.c i = read(fd, buf, BSIZE); fd 625 user/usertests.c close(fd); fd 636 user/usertests.c int i, fd; fd 644 user/usertests.c fd = open(name, O_CREATE|O_RDWR); fd 645 user/usertests.c close(fd); fd 681 user/usertests.c int fd, xstatus, pid; fd 693 user/usertests.c fd = open("echo-ok", O_CREATE|O_WRONLY); fd 694 user/usertests.c if(fd < 0) { fd 698 user/usertests.c if(fd != 1) { fd 714 user/usertests.c fd = open("echo-ok", O_RDONLY); fd 715 user/usertests.c if(fd < 0) { fd 719 user/usertests.c if (read(fd, buf, 2) != 2) { fd 1009 user/usertests.c int fd = open("stopforking", 0); fd 1010 user/usertests.c if(fd >= 0){ fd 1096 user/usertests.c int fd, pid, i, n, nc, np; fd 1101 user/usertests.c fd = open("sharedfd", O_CREATE|O_RDWR); fd 1102 user/usertests.c if(fd < 0){ fd 1109 user/usertests.c if(write(fd, buf, sizeof(buf)) != sizeof(buf)){ fd 1123 user/usertests.c close(fd); fd 1124 user/usertests.c fd = open("sharedfd", 0); fd 1125 user/usertests.c if(fd < 0){ fd 1130 user/usertests.c while((n = read(fd, buf, sizeof(buf))) > 0){ fd 1138 user/usertests.c close(fd); fd 1153 user/usertests.c int fd, pid, i, j, n, total, pi; fd 1169 user/usertests.c fd = open(fname, O_CREATE | O_RDWR); fd 1170 user/usertests.c if(fd < 0){ fd 1177 user/usertests.c if((n = write(fd, buf, SZ)) != SZ){ fd 1195 user/usertests.c fd = open(fname, 0); fd 1197 user/usertests.c while((n = read(fd, buf, sizeof(buf))) > 0){ fd 1206 user/usertests.c close(fd); fd 1220 user/usertests.c int pid, i, fd, pi; fd 1235 user/usertests.c fd = open(name, O_CREATE | O_RDWR); fd 1236 user/usertests.c if(fd < 0){ fd 1240 user/usertests.c close(fd); fd 1265 user/usertests.c fd = open(name, 0); fd 1266 user/usertests.c if((i == 0 || i >= N/2) && fd < 0){ fd 1269 user/usertests.c } else if((i >= 1 && i < N/2) && fd >= 0){ fd 1273 user/usertests.c if(fd >= 0) fd 1274 user/usertests.c close(fd); fd 1292 user/usertests.c int fd, fd1; fd 1294 user/usertests.c fd = open("unlinkread", O_CREATE | O_RDWR); fd 1295 user/usertests.c if(fd < 0){ fd 1299 user/usertests.c write(fd, "hello", SZ); fd 1300 user/usertests.c close(fd); fd 1302 user/usertests.c fd = open("unlinkread", O_RDWR); fd 1303 user/usertests.c if(fd < 0){ fd 1316 user/usertests.c if(read(fd, buf, sizeof(buf)) != SZ){ fd 1324 user/usertests.c if(write(fd, buf, 10) != 10){ fd 1328 user/usertests.c close(fd); fd 1336 user/usertests.c int fd; fd 1341 user/usertests.c fd = open("lf1", O_CREATE|O_RDWR); fd 1342 user/usertests.c if(fd < 0){ fd 1346 user/usertests.c if(write(fd, "hello", SZ) != SZ){ fd 1350 user/usertests.c close(fd); fd 1363 user/usertests.c fd = open("lf2", 0); fd 1364 user/usertests.c if(fd < 0){ fd 1368 user/usertests.c if(read(fd, buf, sizeof(buf)) != SZ){ fd 1372 user/usertests.c close(fd); fd 1397 user/usertests.c int i, pid, n, fd; fd 1415 user/usertests.c fd = open(file, O_CREATE | O_RDWR); fd 1416 user/usertests.c if(fd < 0){ fd 1420 user/usertests.c close(fd); fd 1433 user/usertests.c fd = open(".", 0); fd 1435 user/usertests.c while(read(fd, &de, sizeof(de)) > 0){ fd 1452 user/usertests.c close(fd); fd 1525 user/usertests.c int fd, cc; fd 1533 user/usertests.c fd = open("dd/ff", O_CREATE | O_RDWR); fd 1534 user/usertests.c if(fd < 0){ fd 1538 user/usertests.c write(fd, "ff", 2); fd 1539 user/usertests.c close(fd); fd 1551 user/usertests.c fd = open("dd/dd/ff", O_CREATE | O_RDWR); fd 1552 user/usertests.c if(fd < 0){ fd 1556 user/usertests.c write(fd, "FF", 2); fd 1557 user/usertests.c close(fd); fd 1559 user/usertests.c fd = open("dd/dd/../ff", 0); fd 1560 user/usertests.c if(fd < 0){ fd 1564 user/usertests.c cc = read(fd, buf, sizeof(buf)); fd 1569 user/usertests.c close(fd); fd 1602 user/usertests.c fd = open("dd/dd/ffff", 0); fd 1603 user/usertests.c if(fd < 0){ fd 1607 user/usertests.c if(read(fd, buf, sizeof(buf)) != 2){ fd 1611 user/usertests.c close(fd); fd 1705 user/usertests.c int fd, sz; fd 1709 user/usertests.c fd = open("bigwrite", O_CREATE | O_RDWR); fd 1710 user/usertests.c if(fd < 0){ fd 1716 user/usertests.c int cc = write(fd, buf, sz); fd 1722 user/usertests.c close(fd); fd 1732 user/usertests.c int fd, i, total, cc; fd 1735 user/usertests.c fd = open("bigfile.dat", O_CREATE | O_RDWR); fd 1736 user/usertests.c if(fd < 0){ fd 1742 user/usertests.c if(write(fd, buf, SZ) != SZ){ fd 1747 user/usertests.c close(fd); fd 1749 user/usertests.c fd = open("bigfile.dat", 0); fd 1750 user/usertests.c if(fd < 0){ fd 1756 user/usertests.c cc = read(fd, buf, SZ/2); fd 1773 user/usertests.c close(fd); fd 1784 user/usertests.c int fd; fd 1796 user/usertests.c fd = open("123456789012345/123456789012345/123456789012345", O_CREATE); fd 1797 user/usertests.c if(fd < 0){ fd 1801 user/usertests.c close(fd); fd 1802 user/usertests.c fd = open("12345678901234/12345678901234/12345678901234", 0); fd 1803 user/usertests.c if(fd < 0){ fd 1807 user/usertests.c close(fd); fd 1867 user/usertests.c int fd; fd 1869 user/usertests.c fd = open("dirfile", O_CREATE); fd 1870 user/usertests.c if(fd < 0){ fd 1874 user/usertests.c close(fd); fd 1879 user/usertests.c fd = open("dirfile/xx", 0); fd 1880 user/usertests.c if(fd >= 0){ fd 1884 user/usertests.c fd = open("dirfile/xx", O_CREATE); fd 1885 user/usertests.c if(fd >= 0){ fd 1906 user/usertests.c fd = open(".", O_RDWR); fd 1907 user/usertests.c if(fd >= 0){ fd 1911 user/usertests.c fd = open(".", 0); fd 1912 user/usertests.c if(write(fd, "x", 1) > 0){ fd 1916 user/usertests.c close(fd); fd 1924 user/usertests.c int i, fd; fd 1938 user/usertests.c fd = open("", O_CREATE); fd 1939 user/usertests.c if(fd >= 0) fd 1940 user/usertests.c close(fd); fd 1941 user/usertests.c fd = open("xx", O_CREATE); fd 1942 user/usertests.c if(fd >= 0) fd 1943 user/usertests.c close(fd); fd 2243 user/usertests.c int fd, n; fd 2246 user/usertests.c fd = open("sbrk", O_CREATE|O_WRONLY); fd 2248 user/usertests.c if(fd < 0) { fd 2252 user/usertests.c if ((n = write(fd, a, PGSIZE)) < 0) { fd 2256 user/usertests.c close(fd); fd 2303 user/usertests.c int pid, fd, xstatus; fd 2314 user/usertests.c fd = open("bigarg-ok", O_CREATE); fd 2315 user/usertests.c close(fd); fd 2325 user/usertests.c fd = open("bigarg-ok", 0); fd 2326 user/usertests.c if(fd < 0){ fd 2330 user/usertests.c close(fd); fd 2352 user/usertests.c int fd = open(name, O_CREATE|O_RDWR); fd 2353 user/usertests.c if(fd < 0){ fd 2359 user/usertests.c int cc = write(fd, buf, BSIZE); fd 2366 user/usertests.c close(fd); fd 2388 user/usertests.c int fd; fd 2389 user/usertests.c fd = open("init", O_RDONLY); fd 2390 user/usertests.c if (fd < 0) { fd 2394 user/usertests.c read(fd, sbrk(0) - 1, -1); fd 2395 user/usertests.c close(fd); fd 2536 user/usertests.c int fd = open(p, O_RDWR|O_CREATE); fd 2537 user/usertests.c write(fd, p, 1); fd 2538 user/usertests.c close(fd); fd 2539 user/usertests.c fd = open(p, O_RDWR); fd 2541 user/usertests.c read(fd, p, 1); fd 2651 user/usertests.c int i, fd; fd 2656 user/usertests.c fd = open("bd", O_CREATE); fd 2657 user/usertests.c if(fd < 0){ fd 2661 user/usertests.c close(fd); fd 2711 user/usertests.c int fd = open(name, O_CREATE | O_RDWR); fd 2712 user/usertests.c if(fd < 0){ fd 2717 user/usertests.c int cc = write(fd, buf, sz); fd 2722 user/usertests.c close(fd); fd 2753 user/usertests.c int fd = open("junk", O_CREATE|O_WRONLY); fd 2754 user/usertests.c if(fd < 0){ fd 2758 user/usertests.c write(fd, (char*)0xffffffffffL, 1); fd 2759 user/usertests.c close(fd); fd 2763 user/usertests.c int fd = open("junk", O_CREATE|O_WRONLY); fd 2764 user/usertests.c if(fd < 0){ fd 2768 user/usertests.c if(write(fd, "x", 1) != 1){ fd 2772 user/usertests.c close(fd); fd 2832 user/usertests.c int fd = open(name, O_CREATE|O_RDWR|O_TRUNC); fd 2833 user/usertests.c if(fd < 0){ fd 2841 user/usertests.c if(write(fd, buf, BSIZE) != BSIZE){ fd 2843 user/usertests.c close(fd); fd 2847 user/usertests.c close(fd); fd 2863 user/usertests.c int fd = open(name, O_CREATE|O_RDWR|O_TRUNC); fd 2864 user/usertests.c if(fd < 0) fd 2866 user/usertests.c close(fd); fd 2908 user/usertests.c int fd = open(name, O_CREATE|O_RDWR|O_TRUNC); fd 2909 user/usertests.c if(fd < 0){ fd 2913 user/usertests.c close(fd); fd 8 user/wc.c wc(int fd, char *name) fd 15 user/wc.c while((n = read(fd, buf, sizeof(buf))) > 0){ fd 38 user/wc.c int fd, i; fd 46 user/wc.c if((fd = open(argv[i], 0)) < 0){ fd 50 user/wc.c wc(fd, argv[i]); fd 51 user/wc.c close(fd);