* NAME: file->flush() * DESCRIPTION: flush all pending changes to an open file */
| 492 | * DESCRIPTION: flush all pending changes to an open file |
| 493 | */ |
| 494 | int f_flush(hfsfile *file) |
| 495 | { |
| 496 | hfsvol *vol = file->vol; |
| 497 | |
| 498 | if (vol->flags & HFS_VOL_READONLY) |
| 499 | goto done; |
| 500 | |
| 501 | if (file->flags & HFS_FILE_UPDATE_CATREC) |
| 502 | { |
| 503 | node n; |
| 504 | |
| 505 | file->cat.u.fil.filStBlk = file->cat.u.fil.filExtRec[0].xdrStABN; |
| 506 | file->cat.u.fil.filRStBlk = file->cat.u.fil.filRExtRec[0].xdrStABN; |
| 507 | |
| 508 | if (v_catsearch(vol, file->parid, file->name, 0, 0, &n) <= 0 || |
| 509 | v_putcatrec(&file->cat, &n) == -1) |
| 510 | goto fail; |
| 511 | |
| 512 | file->flags &= ~HFS_FILE_UPDATE_CATREC; |
| 513 | } |
| 514 | |
| 515 | done: |
| 516 | return 0; |
| 517 | |
| 518 | fail: |
| 519 | return -1; |
| 520 | } |
no test coverage detected