// See also nmt_mount_quick() int nmt_mount (char *file) { int result = 0; if (!util_starts_with(file,NETWORK_SHARE)) { // Assume anything not in NETWORK_SHARE is mounted. result = 1; } else { TRACE; char *path = network_mount_point(file); if (path) { TRACE; // check if weve tried mounting. result is set if we have. char *mount_status = get_mount_status(path); TRACE; if (STRCMP(mount_status,MOUNT_STATUS_OK) == 0) { TRACE; result = 1; } else if (STRCMP(mount_status,MOUNT_STATUS_BAD) == 0) { TRACE; result = 0; } else if (STRCMP(mount_status,MOUNT_STATUS_NOT_IN_MTAB) == 0) { result = nmt_mount_share(path,mount_status); } else { TRACE; // MOUNT_STATUS_IN_MTAB or MOUNT_STATUS_NOT_IN_MTAB result = nmt_mount_share(path,mount_status); } FREE(path); } } if (result != 1) { HTML_LOG(0,"Error: mount [%s] = [%d]",file,result); } return result; }
short int FS_MOUNT(unsigned short flag, struct vpfsi *pvpfsi, struct vpfsd *pvpfsd, unsigned short hVPB, unsigned short vol_descr, unsigned char *pBoot) { unsigned short oldVPB; unsigned long len_parm; unsigned char label[CCHMAXPATH], maclabel[HFS_MAX_VLEN+1]; hfsvolent volent; #ifdef DEBUG printf("Mount, flag = %hu, hVPB = %hu\n", flag, hVPB); #endif switch(flag) { case MOUNT_MOUNT: /* The cache uses hVPB as part of the key, so we flush it here. */ flush_cache(); /* Check for duplicate VPB */ oldVPB = hVPB; if( do_FSCtl(NULL, 0, NULL, &oldVPB, sizeof(unsigned short), &len_parm, FSCTL_FUNC_FINDDUPHVPB) == NO_ERROR ) { /* We should read the vol info and bitmap again here for the old VPB, as the volume may have been written while it was removed. */ /* Mark the VPB as duplicate */ set_vol_status(hVPB, pvpfsi->vpi_drive, MTSTAT_DUPLICATE); /* If necessary, mark the old VPB as mounted */ if(get_mount_status(oldVPB)==MTSTAT_REMOVED) set_vol_status(oldVPB, pvpfsi->vpi_drive, MTSTAT_MOUNTED); return NO_ERROR; } /* Mount the volume */ pvpfsd->vol = hfs_mount(hVPB, 1, pvpfsi->vpi_bsize, 0); if(pvpfsd->vol == NULL) { #ifdef DEBUG printf("hfs_mount failed!\n"); #endif return ERROR_VOLUME_NOT_MOUNTED; } if(hfs_vstat(pvpfsd->vol, &volent) < 0) { #ifdef DEBUG printf("hfs_vstat failed!\n"); #endif return ERROR_VOLUME_NOT_MOUNTED; } /* Fill vpfsi fields */ /* Use creation timestamp as ID */ pvpfsi->vpi_vid = volent.crdate; strcpy(maclabel, pvpfsd->vol->mdb.drVN); mac_to_os2_label(maclabel, label); strncpy(pvpfsi->vpi_text, label, 12); pvpfsi->vpi_text[11]=0; set_vol_status(hVPB, pvpfsi->vpi_drive, MTSTAT_MOUNTED); if(is_readonly(hVPB, pvpfsd->vol)) pvpfsd->vol->flags |= HFS_READONLY; #ifdef DEBUG printf("Got HFS volume\n"); #endif return NO_ERROR; case MOUNT_VOL_REMOVED: flush_cache(); /* If the disk was removed, forget about flushing. We should do a setvolume() here if volume is dirty, but it does not work. */ pvpfsd->vol->flags |= HFS_READONLY; return NO_ERROR; case MOUNT_RELEASE: switch(get_mount_status(hVPB)) { case MTSTAT_REMOVED: case MTSTAT_MOUNTED: hfs_umount(pvpfsd->vol); break; case MTSTAT_DUPLICATE: #ifdef DEBUG printf("Trying to unmount non-mounted volume!\n"); #endif break; } flush_cache(); set_vol_status(hVPB, 0, MTSTAT_FREE); return NO_ERROR; case MOUNT_ACCEPT: return ERROR_NOT_SUPPORTED; default: return ERROR_NOT_SUPPORTED; } }