예제 #1
0
파일: rm.py 프로젝트: jtauber/pyv6
def main(argc, argv):
    
    if argc < 2:
        printf(2, "Usage: rm files...\n")
        exit_()
    
    for i in range(1, argc):
        if unlink(argv[i]) < 0:
            printf(2, "rm: %s failed to delete\n", argv[i])
            break
    
    exit_()
예제 #2
0
파일: usertests.py 프로젝트: jtauber/pyv6
def createtest():
    printf(stdout, "many creates, followed by unlink test\n")
    
    name = [None, None, None]
    
    name[0] = "a"
    name[2] = "\0"
    
    for i in range(52):
        name[1] = chr(ord("0") + i)
        fd = open_("".join(name), O_CREATE | O_RDWR)
        close(fd)
    
    name[0] = "a"
    name[2] = "\0"
    
    for i in range(52):
        name[1] = chr(ord("0") + i)
        unlink("".join(name))
    
    printf(stdout, "many creates, followed by unlink; ok\n")
예제 #3
0
파일: usertests.py 프로젝트: jtauber/pyv6
def writetest1():
    buf = "\0" * 2048
    
    printf(stdout, "big files test\n")
    
    fd = open_("big", O_CREATE | O_RDWR)
    
    if fd < 0:
        printf(stdout, "error: creat big failed!\n")
        exit_()
    
    for i in range(MAXFILE):
        buf = chr(i % 256) + buf[1:]
        
        if write(fd, buf, 512) != 512:
            printf(stdout, "error: write big file failed\n", i)
            exit_()
    
    close(fd)
    
    fd = open_("big", O_RDONLY)
    
    if fd < 0:
        printf(stdout, "error: open big failed!\n")
        exit_()
    
    n = 0
    while True:
        i, buf = read(fd, 512)
        if i == 0:
            if n == MAXFILE - 1:
                printf(stdout, "read only %d blocks from big", n)
                exit_()
            break
        elif i != 512:
            printf(stdout, "read failed %d\n", i)
            exit_()
        
        if buf[0] != chr(n % 256):
            printf(stdout, "read content of block %d is %d\n", n, buf[0])
            exit_()
        n += 1
    
    close(fd)
    
    if unlink("big") < 0:
        printf(stdout, "unlink big failed\n")
        exit_()
    printf(stdout, "big files ok\n")
예제 #4
0
파일: usertests.py 프로젝트: jtauber/pyv6
def writetest():
    
    printf(stdout, "small file test\n")
    fd = open_("small", O_CREATE | O_RDWR)
    if fd >= 0:
        printf(stdout, "creat small succeeded; ok\n")
    else:
        printf(stdout, "error: creat small failed!\n")
        exit_()
    
    for i in range(100):
        if write(fd, "aaaaaaaaaa", 10) != 10:
            printf(stdout, "error: write aa %d new file failed\n", i)
            exit_()
        if write(fd, "bbbbbbbbbb", 10) != 10:
            printf(stdout, "error: write bb %d new file failed\n", i)
            exit_()
    
    printf(stdout, "writes ok\n")
    close(fd)
    fd = open_("small", O_RDONLY)
    
    if fd >= 0:
        printf(stdout, "open small succeeded ok\n")
    else:
        printf(stdout, "error: open small failed!\n")
        exit_()
    
    i, buf = read(fd, 2000)
    if i == 2000:
        printf(stdout, "read succeeded ok\n")
    else:
        printf(stdout, "read failed\n")
        exit_()
    close(fd)
    
    if unlink("small") < 0:
        printf(stdout, "unlink small failed\n")
        exit_()
    
    printf(stdout, "small file test ok\n")