read error/quirk with minix 2.0.2 - Minix

This is a discussion on read error/quirk with minix 2.0.2 - Minix ; comp.os.minix read error/quirk with minix 2.0.2 The code below generates an EBADFS error (9 - file descripter not valid for reading) at the read instruction. Anyone know what is neccessary to enable reading a file that has just been writen? ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: read error/quirk with minix 2.0.2

  1. read error/quirk with minix 2.0.2

    comp.os.minix
    read error/quirk with minix 2.0.2

    The code below generates an EBADFS error (9 - file descripter not valid for
    reading) at the read instruction. Anyone know what is neccessary to enable
    reading a file that has just been writen?

    Hul

    ----------------------------------------------------
    extern int creat();
    extern int write();
    extern int read();
    extern long lseek();
    extern int errno;

    main()
    {
    char sp[550];
    char c;
    int x, y, pmode, tst1;
    long xl;
    c = 0x30;
    pmode = 0666;
    tst1 = creat("tst1", pmode);
    if(tst1 <= 0)
    {
    write(1, "error 1", 7);
    return;
    }
    x = write(tst1, &sp[0], 80);
    if(x != 80)
    {
    write(1, "error 2", 7);
    return;
    }
    xl = lseek(tst1, (long) 0, (int) 0);
    if(xl != 0)
    {
    write(1, "error 3", 7);
    return;
    }
    x = read(tst1, &sp[0], 30);
    if(x <= 0)
    {
    write(1, "error 4 = ", 10);
    c = c + errno;
    write(1, &c, 1);
    return;
    }
    close(tst1);
    return;
    }

  2. Re: read error/quirk with minix 2.0.2

    Hul Tytus wrote:
    > comp.os.minix
    > read error/quirk with minix 2.0.2
    >
    > The code below generates an EBADFS error (9 - file descripter not valid for
    > reading) at the read instruction. Anyone know what is neccessary to enable
    > reading a file that has just been writen?



    $ man creat
    $ man open

    creat() is equivalent to open() with flags equal to:
    O_CREAT|O_WRONLY|O_TRUNC.


    Ciao
    Giovanni
    --
    A computer is like an air conditioner,
    it stops working when you open Windows.
    Registered Linux user #337974 < http://giovanni.homelinux.net/ >

+ Reply to Thread