version 1.5, 2005/02/26 03:39:29
|
version 1.6, 2005/02/26 04:24:52
|
|
|
/* File did not exist */ | /* File did not exist */ |
if ((flags & O_CREAT) == 0) { | if ((flags & O_CREAT) == 0) { |
/* ENOENT */ | /* ENOENT */ |
|
#ifdef DEBUG |
|
printf("tvfs_open returning -1\n"); |
|
#endif |
return -1; | return -1; |
} | } |
inode = tvfs_create(fname, 0, 0); | inode = tvfs_create(fname, 0, 0); |
|
|
handler->pos=0; | handler->pos=0; |
h = nfiles++; | h = nfiles++; |
handles[h] = handler; | handles[h] = handler; |
|
#ifdef DEBUG |
|
printf("tvfs_open returning with %d\n", h); |
|
#endif |
|
|
return h; | return h; |
} | } |
| |
|
|
| |
/* Compare given file with given contents, return 0 on equal, else nonzero */ | /* Compare given file with given contents, return 0 on equal, else nonzero */ |
int tvfs_compare(const char *fname, const char *buf, int len){ | int tvfs_compare(const char *fname, const char *buf, int len){ |
|
|
|
char filebuf[MAXFLEN]; |
|
|
|
for (inode=0; inode<nfiles; inode++) { |
|
if (!files[inode]) |
|
continue; |
|
if (!strcmp(files[inode]->fname, fname)) |
|
break; } |
|
|
|
|
#ifdef DEBUG | #ifdef DEBUG |
printf("tvfs_compare called with %s, %d, %d\n", fname, buf, len); | printf("tvfs_compare called with %s, %d, %d\n", fname, buf, len); |
#endif | #endif |
|
|
| |
unsigned int tvfs_write(int h, void *buf, unsigned int len) | unsigned int tvfs_write(int h, void *buf, unsigned int len) |
{ | { |
|
|
|
int inode = handles[h]->inode; |
|
int pos = handles[h]->pos; |
|
|
printf("tvfs_write called with %d, %d, %d\n", h, buf, len); | printf("tvfs_write called with %d, %d, %d\n", h, buf, len); |
|
|
|
memcpy(files[inode]->buf+pos, buf, len); |
|
files[inode]->bytes_used += len; |
|
|
return len; | return len; |
/* return -1 to simulate diskfull or some other error */ | /* return -1 to simulate diskfull or some other error */ |
} | } |