Lines Matching refs:tftpfile
99 static ssize_t tftp_size_of_file(struct tftp_handle *tftpfile);
254 struct tftp_handle *tftpfile; in tftp_open() local
258 tftpfile = (struct tftp_handle *)alloc(sizeof(*tftpfile)); in tftp_open()
259 if (!tftpfile) in tftp_open()
262 tftpfile->iodesc = io = socktodesc(*(int *)(f->f_devdata)); in tftp_open()
264 tftpfile->off = 0; in tftp_open()
265 tftpfile->path = path; /* XXXXXXX we hope it's static */ in tftp_open()
267 res = tftp_makereq(tftpfile); in tftp_open()
270 dealloc(tftpfile, sizeof(*tftpfile)); in tftp_open()
273 f->f_fsdata = (void *)tftpfile; in tftp_open()
281 struct tftp_handle *tftpfile; in tftp_read() local
285 tftpfile = (struct tftp_handle *)f->f_fsdata; in tftp_read()
291 needblock = tftpfile->off / SEGSIZE + 1; in tftp_read()
293 if (tftpfile->currblock > needblock) { /* seek backwards */ in tftp_read()
295 tftp_terminate(tftpfile); in tftp_read()
297 tftp_makereq(tftpfile); /* no error check, it worked in tftp_read()
301 while (tftpfile->currblock < needblock) { in tftp_read()
309 res = tftp_getnextblock(tftpfile); in tftp_read()
313 __func__, tftpfile->currblock, needblock); in tftp_read()
317 if (tftpfile->islastblock) in tftp_read()
321 if (tftpfile->currblock == needblock) { in tftp_read()
324 offinblock = tftpfile->off % SEGSIZE; in tftp_read()
326 if ((int)offinblock > tftpfile->validsize) { in tftp_read()
329 tftpfile->off); in tftp_read()
333 inbuffer = tftpfile->validsize - offinblock; in tftp_read()
336 tftpfile->lastdata.t.th_data + offinblock, in tftp_read()
340 tftpfile->off += count; in tftp_read()
343 if ((tftpfile->islastblock) && (count == inbuffer)) in tftp_read()
363 struct tftp_handle *tftpfile; in tftp_close() local
364 tftpfile = (struct tftp_handle *)f->f_fsdata; in tftp_close()
369 tftp_terminate(tftpfile); in tftp_close()
372 dealloc(tftpfile, sizeof(*tftpfile)); in tftp_close()
384 tftp_size_of_file(struct tftp_handle *tftpfile) in tftp_size_of_file() argument
388 if (tftpfile->currblock > 1) { /* move to start of file */ in tftp_size_of_file()
390 tftp_terminate(tftpfile); in tftp_size_of_file()
392 tftp_makereq(tftpfile); /* no error check, it worked in tftp_size_of_file()
397 filesize = tftpfile->validsize; in tftp_size_of_file()
400 while (!tftpfile->islastblock) { in tftp_size_of_file()
403 res = tftp_getnextblock(tftpfile); in tftp_size_of_file()
407 __func__, tftpfile->currblock); in tftp_size_of_file()
411 filesize += tftpfile->validsize; in tftp_size_of_file()
422 struct tftp_handle *tftpfile; in tftp_stat() local
423 tftpfile = (struct tftp_handle *)f->f_fsdata; in tftp_stat()
429 sb->st_size = tftp_size_of_file(tftpfile); in tftp_stat()
445 struct tftp_handle *tftpfile; in tftp_seek() local
446 tftpfile = (struct tftp_handle *)f->f_fsdata; in tftp_seek()
450 tftpfile->off = offset; in tftp_seek()
453 tftpfile->off += offset; in tftp_seek()
459 return tftpfile->off; in tftp_seek()