I used the read() function to read the contents from a file but got a -1 return value. The file is not empty, I think it might be the problem of data type, but I am not sure. The contents of the file are like this: 1e00 000a 0600 0003 0100 0004 0300 0005 0800 0006 0900 0007 0b00 0003 0c00 0009 Thanks in advance.
#define swapFname "test.disk"
int main(int argc, char const *argv[])
{
    int diskfd;
    unsigned *buf;
    diskfd = open (swapFname, O_RDWR | O_CREAT, 0600);
    int location = (2-2) * 16 * 8 + 0*8; // 0
    int ret = lseek (diskfd, location, SEEK_SET);
    int retsize = read (diskfd, (char *)buf, 32);
    if (retsize < 0)
    { printf ("Error: Disk read returned incorrect size: %d\n", retsize); 
        exit(-1);
    }
}
 
     
    