Example #1
0
int Disk_Thread::Poll_vfs(int dev, bool *ping)
{
    PVFS_FILESYS        VfsSys       = &FileSys;

    /* Try to get media info for device; most probably not possible
       under Windows in case the device is locked / opened!
       -> Remove files from list in case device is/gets mounted
    */
    if(!NT_SUCCESS(VfsGetMediaInfo(VfsSys))){
        lock->lock();

        *this->pFileCounter = 0;
        // DiskRemovebeep is connected to clearFileListWidget which sets the counter to 0xffffffff
        emit DiskRemovebeep();
        while(*this->pFileCounter != 0xffffffff) { // sync thread
            lock->unlock();
            // Give the myform thread the chance to update the variable (task switch)
            msleep(1);
            lock->lock();
        }

        lock->unlock();

        VfsCloseDevice(VfsSys);
        Unmount(DRIVER_MAGIC);
        *ping = true;
    }
    return dev;
}
void FPakPlatformFile::HandleUnmountCommand(const TCHAR* Cmd, FOutputDevice& Ar)
{
	const FString PakFilename = FParse::Token(Cmd, false);
	if (!PakFilename.IsEmpty())
	{
		Unmount(*PakFilename);
	}
}
Example #3
0
void DeviceView::contextMenuEvent(QContextMenuEvent* e) {
  if (!device_menu_) {
    device_menu_ = new QMenu(this);
    library_menu_ = new QMenu(this);

    // Device menu
    eject_action_ = device_menu_->addAction(
        IconLoader::Load("media-eject"), tr("Safely remove device"), this, SLOT(Unmount()));
    forget_action_ = device_menu_->addAction(
        IconLoader::Load("list-remove"), tr("Forget device"), this, SLOT(Forget()));
    device_menu_->addSeparator();
    properties_action_ = device_menu_->addAction(
        IconLoader::Load("configure"), tr("Device properties..."), this, SLOT(Properties()));

    // Library menu
    add_to_playlist_action_ = library_menu_->addAction(IconLoader::Load("media-playback-start"),
        tr("Append to current playlist"), this, SLOT(AddToPlaylist()));
    load_action_ = library_menu_->addAction(IconLoader::Load("media-playback-start"),
        tr("Replace current playlist"), this, SLOT(Load()));
    open_in_new_playlist_ = library_menu_->addAction(IconLoader::Load("document-new"),
        tr("Open in new playlist"), this, SLOT(OpenInNewPlaylist()));
    library_menu_->addSeparator();
    organise_action_ = library_menu_->addAction(IconLoader::Load("edit-copy"),
        tr("Copy to library..."), this, SLOT(Organise()));
    delete_action_ = library_menu_->addAction(IconLoader::Load("edit-delete"),
        tr("Delete from device..."), this, SLOT(Delete()));
  }

  menu_index_ = currentIndex();

  const QModelIndex device_index = MapToDevice(menu_index_);
  const QModelIndex library_index = MapToLibrary(menu_index_);

  if (device_index.isValid()) {
    const bool is_plugged_in = app_->device_manager()->GetLister(device_index.row());
    const bool is_remembered = app_->device_manager()->GetDatabaseId(device_index.row()) != -1;

    forget_action_->setEnabled(is_remembered);
    eject_action_->setEnabled(is_plugged_in);

    device_menu_->popup(e->globalPos());
  } else if (library_index.isValid()) {
    const QModelIndex parent_device_index = FindParentDevice(menu_index_);

    bool is_filesystem_device = false;
    if (parent_device_index.isValid()) {
      boost::shared_ptr<ConnectedDevice> device = app_->device_manager()->GetConnectedDevice(parent_device_index.row());
      if (device && !device->LocalPath().isEmpty())
        is_filesystem_device = true;
    }

    organise_action_->setEnabled(is_filesystem_device);

    library_menu_->popup(e->globalPos());
  }
}
Example #4
0
// destructor
ClientVolume::~ClientVolume()
{
	Unmount();

	if (fShare)
		fShare->ReleaseReference();

	delete fNodeHandles;
	delete fSecurityContext;
}
Example #5
0
Volume::~Volume()
{
	DualErr derr;

	if (Mounted())
	{
		if (AttachedToLocalVolume())
		{
			DetachLocalVolume();
		}
		else
		{
			derr = Unmount();
			pgpAssert(derr.IsntError());
		}
	}
}
Example #6
0
// Mount
status_t
ClientVolume::Mount(UserSecurityContext* securityContext, Share* share)
{
	if (!securityContext || !share)
		return B_BAD_VALUE;
	ObjectDeleter<UserSecurityContext> securityContextDeleter(securityContext);
	if (IsMounted())
		return B_BAD_VALUE;
	fSecurityContext = securityContext;
	securityContextDeleter.Detach();

	fShare = share;
	fShare->AcquireReference();
	dev_t volumeID = share->GetVolumeID();
	ino_t nodeID = share->GetNodeID();

	// into root node ref
	fRootNodeRef.device = volumeID;
	fRootNodeRef.node = nodeID;

	// get the share permissions
	fSharePermissions = securityContext->GetNodePermissions(volumeID, nodeID);

	// get the root directory
	VolumeManager* volumeManager = VolumeManager::GetDefault();
	Directory* rootDir;
	status_t error = volumeManager->LoadDirectory(volumeID, nodeID, &rootDir);
	if (error != B_OK)
		return error;

	// register with the volume manager
	error = volumeManager->AddClientVolume(this);
	if (error != B_OK) {
		Unmount();
		return error;
	}
	fMounted = true;

	// notify the statistics manager
	StatisticsManager::GetDefault()->ShareMounted(fShare,
		fSecurityContext->GetUser());

	return B_OK;
}
void RageFileManager::Mount( CString Type, CString Root, CString MountPoint )
{
	LockMut( *g_Mutex );

	FixSlashesInPlace( Root );
	FixSlashesInPlace( MountPoint );

	if( MountPoint.size() && MountPoint.Right(1) != "/" )
		MountPoint += '/';
	ASSERT( Root != "" );

	CHECKPOINT_M( ssprintf("\"%s\", \"%s\", \"%s\"",
		Type.c_str(), Root.c_str(), MountPoint.c_str() ) );

	// Unmount anything that was previously mounted here.
	Unmount( Type, Root, MountPoint );

	CHECKPOINT;
	RageFileDriver *driver = MakeFileDriver( Type, Root );
	if( !driver )
	{
		CHECKPOINT;

		if( LOG )
			LOG->Warn("Can't mount unknown VFS type \"%s\", root \"%s\"", Type.c_str(), Root.c_str() );
		else
			fprintf( stderr, "Can't mount unknown VFS type \"%s\", root \"%s\"\n", Type.c_str(), Root.c_str() );
		return;
	}

	CHECKPOINT;

	LoadedDriver ld;
	ld.driver = driver;
	ld.Type = Type;
	ld.Root = Root;
	ld.MountPoint = MountPoint;
	g_Drivers.push_back( ld );

	CHECKPOINT;
	g_Mountpoints->LoadFromDrivers( g_Drivers );
	CHECKPOINT;
}
Example #8
0
PGPdisk::~PGPdisk()
{
	if (Mounted())
		Unmount(TRUE);

	if (NULL!=(int)(mContextB))
	{
		mContextB->~CipherContext();
		mContextB = NULL;
	}

	if (NULL!=(int)(mContextA))
	{
		mContextA->~CipherContext();
		mContextA = NULL;
	}

	if (NULL!=(int)(mDataBuf))
	{
		FreeByteBuffer(mDataBuf);
		mDataBuf = NULL;
	}
}
Example #9
0
// Mount
status_t
Volume::Mount(uint32 flags)
{
	Unmount();

	// check the locker's semaphores
	if (fLocker.Sem() < 0)
		return fLocker.Sem();
	if (fIteratorLocker.Sem() < 0)
		return fIteratorLocker.Sem();
	if (fQueryLocker.Sem() < 0)
		return fQueryLocker.Sem();

	status_t error = B_OK;
	fID = id;
	// create a block allocator
	if (error == B_OK) {
		fBlockAllocator = new(nothrow) BlockAllocator(kDefaultAreaSize);
		if (fBlockAllocator)
			error = fBlockAllocator->InitCheck();
		else
			SET_ERROR(error, B_NO_MEMORY);
	}
	// create the listener trees
	if (error == B_OK) {
		fNodeListeners = new(nothrow) NodeListenerTree;
		if (!fNodeListeners)
			error = B_NO_MEMORY;
	}
	if (error == B_OK) {
		fEntryListeners = new(nothrow) EntryListenerTree;
		if (!fEntryListeners)
			error = B_NO_MEMORY;
	}
	// create the node table
	if (error == B_OK) {
		fNodeTable = new(nothrow) NodeTable;
		if (fNodeTable)
			error = fNodeTable->InitCheck();
		else
			SET_ERROR(error, B_NO_MEMORY);
	}
	// create the directory entry table
	if (error == B_OK) {
		fDirectoryEntryTable = new(nothrow) DirectoryEntryTable;
		if (fDirectoryEntryTable)
			error = fDirectoryEntryTable->InitCheck();
		else
			SET_ERROR(error, B_NO_MEMORY);
	}
	// create the node attribute table
	if (error == B_OK) {
		fNodeAttributeTable = new(nothrow) NodeAttributeTable;
		if (fNodeAttributeTable)
			error = fNodeAttributeTable->InitCheck();
		else
			SET_ERROR(error, B_NO_MEMORY);
	}
	// create the index directory
	if (error == B_OK) {
		fIndexDirectory = new(nothrow) IndexDirectory(this);
		if (!fIndexDirectory)
			SET_ERROR(error, B_NO_MEMORY);
	}
	// create the root dir
	if (error == B_OK) {
		fRootDirectory = new(nothrow) Directory(this);
		if (fRootDirectory) {
			// set permissions: -rwxr-xr-x
			fRootDirectory->SetMode(
				S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
			error = fRootDirectory->Link(NULL);
		} else
			SET_ERROR(error, B_NO_MEMORY);
	}
	// set mounted flag / cleanup on error
	if (error == B_OK)
		fMounted = true;
	else
		Unmount();
	RETURN_ERROR(error);
}
bool FPakPlatformFile::HandleUnmountPakDelegate(const FString& PakFilePath)
{
	return Unmount(*PakFilePath);
}
Example #11
0
int __cdecl
wmain(int argc, PWCHAR argv[])
{
	size_t	i;
    WCHAR	fileName[MAX_PATH];
    WCHAR	driverFullPath[MAX_PATH] = { 0 };
    WCHAR	mounterFullPath[MAX_PATH] = { 0 };
    WCHAR	type;

    //setlocale(LC_ALL, "");

    GetModuleFileName(NULL, fileName, MAX_PATH);
    
    // search the last "\"
    for(i = wcslen(fileName) - 1; i > 0 && fileName[i] != L'\\'; --i)
    {
        ;
    }
    fileName[i] = L'\0';

    wcscpy_s(mounterFullPath, MAX_PATH, fileName);
    wcscat_s(mounterFullPath, MAX_PATH, L"\\mounter.exe");
    fwprintf(stderr, L"mounter path %s\n", mounterFullPath);

    GetSystemDirectory(driverFullPath, MAX_PATH);
    wcscat_s(driverFullPath, MAX_PATH, L"\\drivers\\dokan.sys");

    fwprintf(stderr, L"driver path %s\n", driverFullPath);
    

    if (GetOption(argc, argv, 1) == L'v') {
        fprintf(stderr, "dokanctl : %s %s\n", __DATE__, __TIME__);
        fprintf(stderr, "Dokan version : %d\n", DokanVersion());
        fprintf(stderr, "Dokan driver version : 0x%X\n", DokanDriverVersion());
        return 0;
    
    } else if (GetOption(argc, argv, 1) == L'm') {
        return ShowMountList();

    } else if (GetOption(argc, argv, 1) == L'u' && argc == 3) {
        return Unmount(argv[2], FALSE);

    } else if (GetOption(argc, argv, 1) == L'u' &&
                GetOption(argc, argv, 3) == L'f' && argc == 4) {
        return Unmount(argv[2], TRUE);

    } else if (argc < 3 || wcslen(argv[1]) != 2 || argv[1][0] != L'/' ) {
        return ShowUsage();
    }

    type = towlower(argv[2][0]);

    switch(towlower(argv[1][1])) {
    case L'i':
        if (type ==  L'd') {
            if (DokanServiceInstall(DOKAN_DRIVER_SERVICE,
                                    SERVICE_FILE_SYSTEM_DRIVER,
                                    driverFullPath))
                fprintf(stderr, "driver install ok");
            else
                fprintf(stderr, "driver install failed");

        } else if (type == L's') {
            if (DokanServiceInstall(DOKAN_MOUNTER_SERVICE,
                                    SERVICE_WIN32_OWN_PROCESS,
                                    mounterFullPath))
                fprintf(stderr, "mounter install ok");
            else
                fprintf(stderr, "mounter install failed");
        
        } else if (type == L'a') {
            if (DokanServiceInstall(DOKAN_DRIVER_SERVICE,
                                    SERVICE_FILE_SYSTEM_DRIVER,
                                    driverFullPath))
                fprintf(stderr, "driver install ok");
            else
                fprintf(stderr, "driver install failed");

            if (DokanServiceInstall(DOKAN_MOUNTER_SERVICE,
                                    SERVICE_WIN32_OWN_PROCESS,
                                    mounterFullPath))
                fprintf(stderr, "mounter install ok");
            else
                fprintf(stderr, "mounter install failed");
        } else if (type == L'n') {
            if (DokanNetworkProviderInstall())
                fprintf(stderr, "network provider install ok");
            else
                fprintf(stderr, "network provider install failed");
        }
        break;

    case L'r':
        if (type == L'd') {
            if (DokanServiceDelete(DOKAN_DRIVER_SERVICE))
                fprintf(stderr, "driver remove ok");
            else
                fprintf(stderr, "driver remvoe failed");
        
        } else if (type == L's') {
            if (DokanServiceDelete(DOKAN_MOUNTER_SERVICE))
                fprintf(stderr, "mounter remove ok");
            else
                fprintf(stderr, "mounter remvoe failed");	
        
        } else if (type == L'a') {
            if (DokanServiceDelete(DOKAN_MOUNTER_SERVICE))
                fprintf(stderr, "mounter remove ok");
            else
                fprintf(stderr, "mounter remvoe failed");	

            if (DokanServiceDelete(DOKAN_DRIVER_SERVICE))
                fprintf(stderr, "driver remove ok");
            else
                fprintf(stderr, "driver remvoe failed");
        } else if (type == L'n') {
            if (DokanNetworkProviderUninstall())
                fprintf(stderr, "network provider remove ok");
            else
                fprintf(stderr, "network provider remove failed");
        }
        break;
    case L'd':
        if (L'0' <= type && type <= L'9') {
            ULONG mode = type - L'0';
            if (DokanSetDebugMode(mode)) {
                fprintf(stderr, "set debug mode ok");
            } else {
                fprintf(stderr, "set debug mode failed");
            }
        }
        break;
    default:
        fprintf(stderr, "unknown option");
    }
    

    return 0;
}
Example #12
0
// Mount
status_t
Volume::Mount(fs_volume *fsVolume, const char *path)
{
	Unmount();
	status_t error = (path ? B_OK : B_BAD_VALUE);
	fFSVolume = fsVolume;
	// load the settings
	if (error == B_OK) {
		fSettings = new(nothrow) Settings;
		if (fSettings)
			error = fSettings->SetTo(path);
		else
			error = B_NO_MEMORY;
	}
	// copy the device name
	if (error == B_OK) {
		fDeviceName = new(nothrow) char[strlen(path) + 1];
		if (fDeviceName)
			strcpy(fDeviceName, path);
		else
			error = B_NO_MEMORY;
	}
	// open disk
	if (error == B_OK) {
		fDevice = open(path, O_RDONLY);
		if (fDevice < 0)
			SET_ERROR(error, errno);
	}
	// read and analyze super block
	if (error == B_OK)
		error = _ReadSuperBlock();

	if (error == B_OK)
		UpdateName(fsVolume->partition);

	// create and init block cache
	if (error == B_OK) {
		fBlockCache = new(nothrow) BlockCache;
		if (fBlockCache)
			error = fBlockCache->Init(fDevice, CountBlocks(), GetBlockSize());
		else
			error = B_NO_MEMORY;
	}
	// create the tree
	if (error == B_OK) {
		fTree = new(nothrow) Tree;
		if (!fTree)
			error = B_NO_MEMORY;
	}
	// get the root node and init the tree
	if (error == B_OK) {
		Block *rootBlock = NULL;
		error = fBlockCache->GetBlock(fSuperBlock->GetRootBlock(), &rootBlock);
REPORT_ERROR(error);
		if (error == B_OK) {
			rootBlock->SetKind(Block::KIND_FORMATTED);
			error = fTree->Init(this, rootBlock->ToNode(),
								fSuperBlock->GetTreeHeight());
REPORT_ERROR(error);
			rootBlock->Put();
		}
	}
	// get the root VNode (i.e. the root dir)
	if (error == B_OK) {
		fRootVNode = new(nothrow) VNode;
		if (fRootVNode) {
			error = FindVNode(REISERFS_ROOT_PARENT_OBJECTID,
							  REISERFS_ROOT_OBJECTID, fRootVNode);
REPORT_ERROR(error);
			if (error == B_OK) {
				error = publish_vnode(fFSVolume, fRootVNode->GetID(),
					fRootVNode, &gReiserFSVnodeOps, S_IFDIR, 0);
			}
REPORT_ERROR(error);
		} else
			error = B_NO_MEMORY;
	}
	// init the hash function
	if (error == B_OK)
		_InitHashFunction();
	// init the negative entry list
	if (error == B_OK)
		_InitNegativeEntries();
	// cleanup on error
	if (error != B_OK)
		Unmount();
	RETURN_ERROR(error);
}
Example #13
0
int __cdecl wmain(int argc, PWCHAR argv[]) {
  size_t i;
  WCHAR fileName[MAX_PATH];
  WCHAR driverFullPath[MAX_PATH] = {0};
  WCHAR type;
  PVOID wow64OldValue;

  DokanUseStdErr(TRUE); // Set dokan library debug output

  Wow64DisableWow64FsRedirection(&wow64OldValue); // Disable system32 direct
  // setlocale(LC_ALL, "");

  GetModuleFileName(NULL, fileName, MAX_PATH);

  // search the last "\"
  for (i = wcslen(fileName) - 1; i > 0 && fileName[i] != L'\\'; --i) {
    ;
  }
  fileName[i] = L'\0';

  ExpandEnvironmentStringsW(DOKAN_DRIVER_FULL_PATH, driverFullPath, MAX_PATH);

  fwprintf(stdout, L"Driver path: '%s'\n", driverFullPath);

  if (GetOption(argc, argv, 1) == L'v') {
    fprintf(stdout, "dokanctl : %s %s\n", __DATE__, __TIME__);
    fprintf(stdout, "Dokan version : %d\n", DokanVersion());
    fprintf(stdout, "Dokan driver version : 0x%lx\n", DokanDriverVersion());
    return EXIT_SUCCESS;

  } else if (GetOption(argc, argv, 1) == L'u' && argc == 3) {
    return Unmount(argv[2], FALSE);

  } else if (GetOption(argc, argv, 1) == L'u' &&
             GetOption(argc, argv, 3) == L'f' && argc == 4) {
    return Unmount(argv[2], TRUE);

  } else if (argc < 3 || wcslen(argv[1]) != 2 || argv[1][0] != L'/') {
    return ShowUsage();
  }

  type = towlower(argv[2][0]);

  switch (towlower(argv[1][1])) {
  case L'i':
    if (type == L'd') {

      return InstallDriver(driverFullPath);

    } else if (type == L'n') {
      if (DokanNetworkProviderInstall())
        fprintf(stdout, "network provider install ok\n");
      else
        fprintf(stderr, "network provider install failed\n");
    }
    break;

  case L'r':
    if (type == L'd') {

      return DeleteDokanService(DOKAN_DRIVER_SERVICE);

    } else if (type == L'n') {
      if (DokanNetworkProviderUninstall())
        fprintf(stdout, "network provider remove ok\n");
      else
        fprintf(stderr, "network provider remove failed\n");
    }
    break;

  case L'd':
    if (L'0' <= type && type <= L'9') {
      ULONG mode = type - L'0';
      if (DokanSetDebugMode(mode)) {
        fprintf(stdout, "set debug mode ok\n");
      } else {
        fprintf(stderr, "set debug mode failed\n");
      }
    }
    break;

  case L'l': {
    ULONG nbRead = 0;
    DOKAN_CONTROL dokanControl[DOKAN_MAX_INSTANCES];
    if (DokanGetMountPointList(dokanControl, DOKAN_MAX_INSTANCES, FALSE,
                               &nbRead)) {
      fwprintf(stdout, L"  Mount points: %d\n", nbRead);
      for (unsigned int p = 0; p < nbRead; ++p) {
        fwprintf(stdout, L"  %d# MountPoint: %s - UNC: %s - DeviceName: %s\n",
                 p, dokanControl[p].MountPoint, dokanControl[p].UNCName,
                 dokanControl[p].DeviceName);
      }
    } else {
      fwprintf(stderr, L"  Cannot retrieve mount point list.\n");
    }
  } break;

  default:
    fprintf(stderr, "unknown option\n");
  }

  return EXIT_SUCCESS;
}
Example #14
0
int __cdecl wmain(int argc, PWCHAR argv[]) {
  size_t i;
  WCHAR fileName[MAX_PATH];
  WCHAR driverFullPath[MAX_PATH] = {0};
  WCHAR mounterFullPath[MAX_PATH] = {0};
  WCHAR type;
  PVOID wow64OldValue;

  DokanUseStdErr(TRUE); // Set dokan library debug output

  Wow64DisableWow64FsRedirection(&wow64OldValue); //Disable system32 direct
  // setlocale(LC_ALL, "");

  GetModuleFileName(NULL, fileName, MAX_PATH);

  // search the last "\"
  for (i = wcslen(fileName) - 1; i > 0 && fileName[i] != L'\\'; --i) {
    ;
  }
  fileName[i] = L'\0';

  wcscpy_s(mounterFullPath, MAX_PATH, fileName);
  wcscat_s(mounterFullPath, MAX_PATH, L"\\mounter.exe");
  fwprintf(stderr, L"Mounter path: '%s'\n", mounterFullPath);

  ExpandEnvironmentStringsW(DOKAN_DRIVER_FULL_PATH, driverFullPath, MAX_PATH);

  fwprintf(stderr, L"Driver path: '%s'\n", driverFullPath);

  if (GetOption(argc, argv, 1) == L'v') {
    fprintf(stderr, "dokanctl : %s %s\n", __DATE__, __TIME__);
    fprintf(stderr, "Dokan version : %d\n", DokanVersion());
    fprintf(stderr, "Dokan driver version : 0x%lx\n", DokanDriverVersion());
    return EXIT_SUCCESS;

  } else if (GetOption(argc, argv, 1) == L'm') {
    return ShowMountList();

  } else if (GetOption(argc, argv, 1) == L'u' && argc == 3) {
    return Unmount(argv[2], FALSE);

  } else if (GetOption(argc, argv, 1) == L'u' &&
             GetOption(argc, argv, 3) == L'f' && argc == 4) {
    return Unmount(argv[2], TRUE);

  } else if (argc < 3 || wcslen(argv[1]) != 2 || argv[1][0] != L'/') {
    return ShowUsage();
  }

  type = towlower(argv[2][0]);

  switch (towlower(argv[1][1])) {
  case L'i':
    if (type == L'd') {

      return InstallDriver(driverFullPath);

    } else if (type == L's') {

      return InstallMounter(mounterFullPath);

    } else if (type == L'a') {

      if (InstallDriver(driverFullPath) == EXIT_FAILURE)
        return EXIT_FAILURE;

      if (InstallMounter(mounterFullPath) == EXIT_FAILURE)
        return EXIT_FAILURE;

    } else if (type == L'n') {
      if (DokanNetworkProviderInstall())
        fprintf(stderr, "network provider install ok\n");
      else
        fprintf(stderr, "network provider install failed\n");
    }
    break;

  case L'r':
    if (type == L'd') {

      return DeleteDokanService(DOKAN_DRIVER_SERVICE);

    } else if (type == L's') {

      return DeleteDokanService(DOKAN_MOUNTER_SERVICE);

    } else if (type == L'a') {

      if (DeleteDokanService(DOKAN_MOUNTER_SERVICE) == EXIT_FAILURE)
        return EXIT_FAILURE;

      if (DeleteDokanService(DOKAN_DRIVER_SERVICE) == EXIT_FAILURE)
        return EXIT_FAILURE;

    } else if (type == L'n') {
      if (DokanNetworkProviderUninstall())
        fprintf(stderr, "network provider remove ok\n");
      else
        fprintf(stderr, "network provider remove failed\n");
    }
    break;
  case L'd':
    if (L'0' <= type && type <= L'9') {
      ULONG mode = type - L'0';
      if (DokanSetDebugMode(mode)) {
        fprintf(stderr, "set debug mode ok\n");
      } else {
        fprintf(stderr, "set debug mode failed\n");
      }
    }
    break;
  default:
    fprintf(stderr, "unknown option\n");
  }

  return EXIT_SUCCESS;
}
Example #15
0
int __cdecl wmain(int argc, PWCHAR argv[]) {
  size_t i;
  WCHAR fileName[MAX_PATH];
  WCHAR driverFullPath[MAX_PATH] = {0};
  PVOID wow64OldValue;
  BOOL isAdmin;

  isAdmin = IsUserAnAdmin();

  DokanUseStdErr(TRUE); // Set dokan library debug output

  Wow64DisableWow64FsRedirection(&wow64OldValue); // Disable system32 direct
  // setlocale(LC_ALL, "");

  GetModuleFileName(NULL, fileName, MAX_PATH);

  // search the last "\"
  for (i = wcslen(fileName) - 1; i > 0 && fileName[i] != L'\\'; --i) {
    ;
  }
  fileName[i] = L'\0';

  ExpandEnvironmentStringsW(DOKAN_DRIVER_FULL_PATH, driverFullPath, MAX_PATH);

  fwprintf(stdout, L"Driver path: '%s'\n", driverFullPath);

  WCHAR option = GetOption(argc, argv, 1);
  if (option == L'\0' || option == L'?') {
    return ShowUsage();
  }

  if (!isAdmin &&
      (option == L'i' || option == L'r' || option == L'd' || option == L'u')) {
    fprintf(stderr, "Admin rights required to process this operation\n");
    return EXIT_FAILURE;
  }

  switch (option) {
  // Admin rights required
  case L'i': {
    WCHAR type = towlower(argv[2][0]);
    if (type == L'd') {
      return InstallDriver(driverFullPath);
    } else if (type == L'n') {
      if (DokanNetworkProviderInstall())
        fprintf(stdout, "network provider install ok\n");
      else
        fprintf(stderr, "network provider install failed\n");
    } else {
      goto DEFAULT;
    }
  } break;

  case L'r': {
    WCHAR type = towlower(argv[2][0]);
    if (type == L'd') {
      return DeleteDokanService(DOKAN_DRIVER_SERVICE);
    } else if (type == L'n') {
      if (DokanNetworkProviderUninstall())
        fprintf(stdout, "network provider remove ok\n");
      else
        fprintf(stderr, "network provider remove failed\n");
    } else {
      goto DEFAULT;
    }
  } break;

  case L'd': {
    WCHAR type = towlower(argv[2][0]);
    if (L'0' > type || type > L'9')
      goto DEFAULT;

    ULONG mode = type - L'0';
    if (DokanSetDebugMode(mode)) {
      fprintf(stdout, "set debug mode ok\n");
    } else {
      fprintf(stderr, "set debug mode failed\n");
    }
  } break;

  case L'u': {
    if (argc < 3) {
      goto DEFAULT;
    }
    return Unmount(argv[2]);
  } break;

  // No admin rights required
  case L'l': {
    ULONG nbRead = 0;
    PDOKAN_CONTROL dokanControl =
        malloc(DOKAN_MAX_INSTANCES * sizeof(*dokanControl));
    if (dokanControl == NULL) {
      fprintf(stderr, "Failed to allocate dokanControl\n");
      return EXIT_FAILURE;
    }

    ZeroMemory(dokanControl, DOKAN_MAX_INSTANCES * sizeof(*dokanControl));
    if (DokanGetMountPointList(dokanControl, DOKAN_MAX_INSTANCES, FALSE,
                               &nbRead)) {
      fwprintf(stdout, L"  Mount points: %d\n", nbRead);
      for (unsigned int p = 0; p < nbRead; ++p) {
        fwprintf(stdout, L"  %u# MountPoint: %s - UNC: %s - DeviceName: %s\n",
                 p, dokanControl[p].MountPoint, dokanControl[p].UNCName,
                 dokanControl[p].DeviceName);
      }
    } else {
      fwprintf(stderr, L"  Cannot retrieve mount point list.\n");
    }
    free(dokanControl);
  } break;

  case L'v': {
    fprintf(stdout, "dokanctl : %s %s\n", __DATE__, __TIME__);
    fprintf(stdout, "Dokan version : %d\n", DokanVersion());
    fprintf(stdout, "Dokan driver version : 0x%lx\n", DokanDriverVersion());
  } break;

  DEFAULT:
  default:
    fprintf(stderr, "Unknown option - Use /? to show usage\n");
  }

  return EXIT_SUCCESS;
}
void NzPluginManager::Unmount(nzPlugin plugin)
{
	Unmount(s_pluginFiles[plugin]);
}
Example #17
0
int Disk_Thread::init_vfs(int dev, bool *ping)
{
    char DevName[50] = {0};
    char textMessage[100] = {0};
    PVFS_FILESYS VfsSys = &FileSys;
    int devNr = dev;
    
#if defined(_WIN32) || defined(_WIN64)
    snprintf(DevName, 50, "\\Device\\Harddisk%d\\Partition0",dev);
#else
    snprintf(DevName, 50, "/dev/sd%c",devNr+'b');
#endif
    printTextBrowser(0);
    snprintf(textMessage, 100, "Test device %s\n", DevName);
    printTextBrowser(textMessage);

    if(VfsDevtoLetter(DevName, DRIVER_MAGIC) == -1) {
        printTextBrowser("Dev not ready!\n");
        dev = 0;
    } else {
#if defined(_WIN32) || defined(_WIN64)
        sprintf(DevName, "%s", DRIVER_MAGIC);
#endif
        if(!NT_SUCCESS(VfsOpenDevice(VfsSys, (PUCHAR)DevName))){
            printTextBrowser("vfs:  Volume does not exist!\n");
#if defined(_WIN32) || defined(_WIN64)
            devNr = 0;
#else
            devNr++;
#endif
        }else{
            qDebug(" DEV OPEN OK");
            VfsGetMediaInfo(VfsSys);
            VfsInit.VfsSys = VfsSys;
            VfsInit.Init   = false;
            VFS_Open(&VfsInit);
            if(VFS_Mount(0) == FAT_OK){
                U32 idx;
                HD_VFS_HANDLER *File = (HD_VFS_HANDLER*)malloc(sizeof(HD_VFS_HANDLER));
            
                printTextBrowser(" Device mounted OK!\n");
                    
                VfsInit.Init   = true;
                *ping          = true;
                    
                *this->pFileCounter =0;
                for(idx = 0;idx < VFS_ROOT_ENTRIES;idx++){
                    if(VFS_GetFileInfobyIndex(idx,File) == FAT_OK){
                        if(File->Inode.status == INODE_BUSY){

                            lock->lock();
                            *this->pFileCounter = idx+1;
                            printf(" VFS loop 0x%x\n",(int)*this->pFileCounter);
                            AddNewVFSHandler(File);
                            while(*this->pFileCounter != 0xffffffff){ // sync thread
                                lock->unlock();
                                msleep(1);
                                lock->lock();
                            }
                            lock->unlock();
                                
                        }
                    }
                }
                free(File);
                return devNr;
            }
            VfsCloseDevice(VfsSys);
            devNr++;
        }
    }
    Unmount(DRIVER_MAGIC);
    return devNr;
}
Example #18
0
// destructor
Volume::~Volume()
{
	Unmount();
}
Example #19
0
VolFile::~VolFile()
{
	if (Mounted())
		Unmount();
}