/* * NAME: hfs->flushall() * DESCRIPTION: flush all pending changes to all mounted HFS volumes */ void hfs_flushall(void) { hfsvol *vol; for (vol = hfs_mounts; vol; vol = vol->next) hfs_flush(vol); }
short int FS_FLUSHBUF(struct vpfsd *vpfsd, unsigned short flag) { if(vpfsd->vol) { if(hfs_flush(vpfsd->vol) < 0) { #ifdef DEBUG printf("FS_FLUSHBUF: hfs_flush() failed!\n"); #endif return ERROR_WRITE_FAULT; } } if(flag==FLUSH_DISCARD) flush_cache(); return NO_ERROR; }
static int FuseHFS_mknod(const char *path, mode_t mode, dev_t rdev) { dprintf("mknod %s\n", path); if (_readonly) return -EPERM; // convert to hfs path char *hfspath = mkhfspath(path); if (hfspath == NULL) return -ENOENT; // open file hfsfile *file; if ((file = hfs_create(NULL, hfspath, "TEXT", "FUSE"))) { // file hfs_close(file); hfs_flush(NULL); free(hfspath); return 0; } dprintf("mknod: EPERM\n"); free(hfspath); return -EPERM; }
static int FuseHFS_flush(const char *path, struct fuse_file_info *fi) { hfs_flush(NULL); return 0; }
/* ** make_mac_volume: "create" an HFS volume using the ISO data ** ** The HFS volume structures are set up (but no data is written yet). ** ** ISO volumes have a allocation size of 2048 bytes - regardless ** of the size of the volume. HFS allocation size is depends on volume ** size, so we may have to update the ISO structures to add in any ** padding. */ int FDECL2(make_mac_volume, struct directory *, dpnt, int, start_extent) { char vol_name[HFS_MAX_VLEN+1]; /* Mac volume name */ hfsvol *vol; /* Mac volume */ int vlen, vblen; /* vol length (bytes, blocks) */ int Csize, lastCsize; /* allocation sizes */ int ret = 0; /* return value */ int loop = 1; /* umount volume if we have had a previous attempt */ if (vol_save) if (hfs_umount(vol_save, 0) < 0) return (-1); /* set the default clump size to the ISO block size */ lastCsize = SECTOR_SIZE; if (verbose > 1) fprintf(stderr, "Creating HFS Volume info\n"); /* name or copy ISO volume name to Mac Volume name */ strncpy(vol_name, hfs_volume_id ? hfs_volume_id : volume_id, HFS_MAX_VLEN); vol_name[HFS_MAX_VLEN] = '\0'; /* get initial size of HFS volume (size of ISO volume) */ vblen = last_extent * BLK_CONV; /* add on size of extents/catalog file, but this may mean the allocation size will change, so loop round until the allocation size doesn't change */ while (loop) { hce->XTCsize = XClpSiz(vblen); vblen = get_vol_size(vblen); Csize = AlcSiz(vblen); if (Csize == lastCsize) { /* allocation size hasn't changed, so carry on */ loop = 0; } else { /* allocation size has changed, so update ISO volume size */ if ((vlen = get_adj_size(Csize)) < 0) { snprintf(hce->error, ERROR_SIZE, "too many files for HFS volume"); return (-1); } vlen += V_ROUND_UP(start_extent * SECTOR_SIZE, Csize); vblen = vlen / HFS_BLOCKSZ; lastCsize = Csize; } } /* set vlen to size in bytes */ /* vlen = hce->hfs_vol_size = vblen * HFS_BLOCKSZ; */ /* take off the label/map size */ vblen -= hce->hfs_map_size; vlen = hce->hfs_vol_size = vblen * HFS_BLOCKSZ; /* set the default allocation size for libhfs */ hce->Csize = Csize; /* format and mount the "volume" */ if (hfs_format(hce, 0, vol_name) < 0) { snprintf(hce->error, ERROR_SIZE, "can't HFS format %s",vol_name); return(-1); } /* update the ISO structures with new start extents and any padding required */ if (Csize != SECTOR_SIZE) { last_extent = adj_size(Csize, start_extent, hce->hfs_hdr_size + hce->hfs_map_size); adj_size_other(dpnt); } if ((vol = hfs_mount(hce, 0, 0)) == 0) { snprintf(hce->error, ERROR_SIZE, "can't HFS mount %s",vol_name); return(-1); } /* save the volume for possible later use */ vol_save = vol; /* Recursively "copy" the files to the volume - we need to know the first allocation block in the volume as starting blocks of files are relative to this. */ ret = copy_to_mac_vol(vol, dpnt); if (ret < 0) return(ret); /* make the Desktop files - I *think* this stops the Mac rebuilding the desktop when the CD is mounted on a Mac These will be ignored if they already exist */ if (create_dt) ret = make_desktop(vol, last_extent*BLK_CONV); if (ret < 0) return(ret); /* close the volume */ if (hfs_flush(vol) < 0) return(-1); /* unmount and set the start blocks for the catalog/extents files */ if (hfs_umount(vol, last_extent*BLK_CONV) < 0) return(-1); return(Csize); }