Exemple #1
0
KURL Medium::prettyBaseURL() const
{
        if ( !baseURL().isEmpty() )
            return baseURL();

		return KURL( mountPoint() );
}
void CalculateSourcePath(LPCTSTR wszSnapshotDevice, LPCTSTR wszBackupSource, LPCTSTR wszMountPoint, CString& output)
{
    CString backupSource(wszBackupSource); 
    CString mountPoint(wszMountPoint); 

    CString subdirectory = backupSource.Mid(mountPoint.GetLength()); 

    Utilities::CombinePath(wszSnapshotDevice, subdirectory, output); 
}
bool
SoundSettings::isTemporaryFile (
        const QString &filePath)
{
    bool     retval = filePath.startsWith(mountPoint());

    SYS_DEBUG ("*** filePath   = %s", SYS_STR(filePath));
    SYS_DEBUG ("*** retval     = %s", SYS_BOOL(retval));

    return retval;
}
//static
void VolumeManager::InitConfig()
{
  MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());

  // This function uses /system/etc/volume.cfg to add additional volumes
  // to the Volume Manager.
  //
  // This is useful on devices like the Nexus 4, which have no physical sd card
  // or dedicated partition.
  //
  // The format of the volume.cfg file is as follows:
  // create volume-name mount-point
  // Blank lines and lines starting with the hash character "#" will be ignored.

  ScopedCloseFile fp;
  int n = 0;
  char line[255];
  char *command, *volNamePtr, *mountPointPtr, *save_ptr;
  const char *filename = "/system/etc/volume.cfg";
  if (!(fp = fopen(filename, "r"))) {
    LOG("Unable to open volume configuration file '%s' - ignoring", filename);
    return;
  }
  while(fgets(line, sizeof(line), fp)) {
    const char *delim = " \t\n";
    n++;

    if (line[0] == '#')
      continue;
    if (!(command = strtok_r(line, delim, &save_ptr))) {
      // Blank line - ignore
      continue;
    }
    if (!strcmp(command, "create")) {
      if (!(volNamePtr = strtok_r(nullptr, delim, &save_ptr))) {
        ERR("No vol_name in %s line %d",  filename, n);
        continue;
      }
      if (!(mountPointPtr = strtok_r(nullptr, delim, &save_ptr))) {
        ERR("No mount point for volume '%s'. %s line %d", volNamePtr, filename, n);
        continue;
      }
      nsCString mountPoint(mountPointPtr);
      nsCString volName(volNamePtr);

      RefPtr<Volume> vol = FindAddVolumeByName(volName);
      vol->SetFakeVolume(mountPoint);
    }
    else {
      ERR("Unrecognized command: '%s'", command);
    }
  }
}
Exemple #5
0
status_t
PackageItem::InitPath(const char *path, BPath *destination)
{
	status_t ret = B_OK;

	if (fPathType == P_INSTALL_PATH) {
		if (!path) {
			parser_debug("InitPath path is NULL\n");
			return B_ERROR;
		}
		ret = destination->SetTo(path, fPath.String());
	}
	else if (fPathType == P_SYSTEM_PATH)
		ret = destination->SetTo(fPath.String());
	else {
		if (!path) {
			parser_debug("InitPath path is NULL\n");
			return B_ERROR;
		}

		BVolume volume(dev_for_path(path));
		ret = volume.InitCheck();
		if (ret != B_OK)
			return ret;

		BDirectory temp;
		ret = volume.GetRootDirectory(&temp);
		if (ret != B_OK)
			return ret;

		BPath mountPoint(&temp, NULL);
		ret = destination->SetTo(mountPoint.Path(), fPath.String());
	}

	return ret;
}
Exemple #6
0
//static
void VolumeManager::InitConfig()
{
  MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());

  // This function uses /system/etc/volume.cfg to add additional volumes
  // to the Volume Manager.
  //
  // This is useful on devices like the Nexus 4, which have no physical sd card
  // or dedicated partition.
  //
  // The format of the volume.cfg file is as follows:
  // create volume-name mount-point
  // configure volume-name preference preference-value
  // Blank lines and lines starting with the hash character "#" will be ignored.

  ScopedCloseFile fp;
  int n = 0;
  char line[255];
  const char *filename = "/system/etc/volume.cfg";
  if (!(fp = fopen(filename, "r"))) {
    LOG("Unable to open volume configuration file '%s' - ignoring", filename);
    return;
  }
  while(fgets(line, sizeof(line), fp)) {
    n++;

    if (line[0] == '#')
      continue;

    nsCString commandline(line);
    nsCWhitespaceTokenizer tokenizer(commandline);
    if (!tokenizer.hasMoreTokens()) {
      // Blank line - ignore
      continue;
    }

    nsCString command(tokenizer.nextToken());
    if (command.EqualsLiteral("create")) {
      if (!tokenizer.hasMoreTokens()) {
        ERR("No vol_name in %s line %d",  filename, n);
        continue;
      }
      nsCString volName(tokenizer.nextToken());
      if (!tokenizer.hasMoreTokens()) {
        ERR("No mount point for volume '%s'. %s line %d",
             volName.get(), filename, n);
        continue;
      }
      nsCString mountPoint(tokenizer.nextToken());
      RefPtr<Volume> vol = FindAddVolumeByName(volName);
      vol->SetFakeVolume(mountPoint);
      continue;
    }
    if (command.EqualsLiteral("configure")) {
      if (!tokenizer.hasMoreTokens()) {
        ERR("No vol_name in %s line %d", filename, n);
        continue;
      }
      nsCString volName(tokenizer.nextToken());
      if (!tokenizer.hasMoreTokens()) {
        ERR("No configuration name specified for volume '%s'. %s line %d",
             volName.get(), filename, n);
        continue;
      }
      nsCString configName(tokenizer.nextToken());
      if (!tokenizer.hasMoreTokens()) {
        ERR("No value for configuration name '%s'. %s line %d",
            configName.get(), filename, n);
        continue;
      }
      nsCString configValue(tokenizer.nextToken());
      RefPtr<Volume> vol = FindVolumeByName(volName);
      if (vol) {
        vol->SetConfig(configName, configValue);
      } else {
        ERR("Invalid volume name '%s'.", volName.get());
      }
      continue;
    }
    if (command.EqualsLiteral("ignore")) {
      // This command is useful to remove volumes which are being tracked by
      // vold, but for which we have no interest.
      if (!tokenizer.hasMoreTokens()) {
        ERR("No vol_name in %s line %d", filename, n);
        continue;
      }
      nsCString volName(tokenizer.nextToken());
      RemoveVolumeByName(volName);
      continue;
    }
    ERR("Unrecognized command: '%s'", command.get());
  }
}
	void MountOptionsDialog::OnOKButtonClick (wxCommandEvent& event)
	{
		bool bUnsupportedKdf = false;

		/* verify that PIM values are valid before continuing*/
		int Pim = PasswordPanel->GetVolumePim();
		int ProtectionPim = (!ReadOnlyCheckBox->IsChecked() && ProtectionCheckBox->IsChecked())?
			ProtectionPasswordPanel->GetVolumePim() : 0;

		/* invalid PIM: set focus to PIM field and stop processing */
		if (-1 == Pim || (PartitionInSystemEncryptionScopeCheckBox->IsChecked() && Pim > MAX_BOOT_PIM_VALUE))
		{
			PasswordPanel->SetFocusToPimTextCtrl();
			return;
		}

		if (-1 == ProtectionPim || (PartitionInSystemEncryptionScopeCheckBox->IsChecked() && ProtectionPim > MAX_BOOT_PIM_VALUE))
		{
			ProtectionPasswordPanel->SetFocusToPimTextCtrl();
			return;
		}

		TransferDataFromWindow();

		try
		{
			Options.Password = PasswordPanel->GetPassword();
		}
		catch (PasswordException& e)
		{
			Gui->ShowWarning (e);
			return;
		}
		Options.Pim = Pim;
		Options.Kdf = PasswordPanel->GetPkcs5Kdf(bUnsupportedKdf);
		if (bUnsupportedKdf)
		{
			Gui->ShowWarning (LangString ["ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"]);
			return;
		}
		Options.TrueCryptMode = PasswordPanel->GetTrueCryptMode();
		Options.Keyfiles = PasswordPanel->GetKeyfiles();

		if (ReadOnlyCheckBox->IsChecked())
		{
			Options.Protection = VolumeProtection::ReadOnly;
		}
		else if (ProtectionCheckBox->IsChecked())
		{
			try
			{
				Options.ProtectionPassword = ProtectionPasswordPanel->GetPassword();
			}
			catch (PasswordException& e)
			{
				Gui->ShowWarning (e);
				return;
			}
			Options.Protection = VolumeProtection::HiddenVolumeReadOnly;
			Options.ProtectionPim = ProtectionPim;
			Options.ProtectionKdf = ProtectionPasswordPanel->GetPkcs5Kdf(Options.TrueCryptMode, bUnsupportedKdf);
			if (bUnsupportedKdf)
			{
				Gui->ShowWarning (LangString ["ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"]);
				return;
			}
			Options.ProtectionKeyfiles = ProtectionPasswordPanel->GetKeyfiles();
		}
		else
		{
			Options.Protection = VolumeProtection::None;
		}

		wstring mountPoint (MountPointTextCtrl->GetValue());
		if (!mountPoint.empty())
			Options.MountPoint = make_shared <DirectoryPath> (mountPoint);

		Options.FilesystemOptions = FilesystemOptionsTextCtrl->GetValue();

		EndModal (wxID_OK);
	}
wxThread::ExitCode PFMMonitorThread::Entry()
{
	const int timeoutMSecs = 50;
	long long startChangeInstance = 0, nextChangeInstance = 0;
	PfmApi *pfmApi = PFMProxy::getInstance().getPfmApi();

	// Get the main frame window
	EncFSMPMainFrame *pMainFrame = NULL;
	wxWindow *pTopWindow = wxTheApp->GetTopWindow();
	if(pTopWindow != NULL)
	{
		pMainFrame = dynamic_cast<EncFSMPMainFrame *>(pTopWindow);
	}

	while(!TestDestroy())
	{
		int retVal = pfmMonitor_->Wait(nextChangeInstance, timeoutMSecs);
		bool sendEvents = true;
		{
			wxMutexLocker lock(mutex_);
			sendEvents = sendEvents_;
		}

		if(sendEvents)
		{
			PfmIterator *iter = NULL;
			pfmApi->MountIterate(startChangeInstance, &nextChangeInstance, &iter);

			long long curChangeInstance = 0;
			int mountId = iter->Next(&curChangeInstance);
			while(mountId > 0)
			{
				if(curChangeInstance >= startChangeInstance)
				{
					PfmMount *curMount = NULL;
					int err = pfmApi->MountIdOpen(mountId, &curMount);

					if(err == 0 && curMount != NULL)
					{
						int statusFlags = curMount->GetStatusFlags();

						std::wstring formatterName(curMount->GetFormatterName());
						std::wstring fileName(curMount->GetMountSourceName());
						wchar_t driveLetter = curMount->GetDriveLetter();
#if !defined(EFS_WIN32)
						driveLetter = L' ';
#endif
						std::wstring ownerName(curMount->GetOwnerName());
						std::wstring ownerId(curMount->GetOwnerId());
						std::wstring mountPoint(curMount->GetMountPoint());

						if(formatterName == EncFSMPStrings::formatterName_)
						{
							if((statusFlags & (pfmStatusFlagReady | pfmStatusFlagDisconnected | pfmStatusFlagClosed)) != 0)
							{
								bool isMountEvent = ((statusFlags & (pfmStatusFlagDisconnected | pfmStatusFlagClosed)) == 0);
								pMainFrame->addNewMountEvent(isMountEvent, false, fileName, driveLetter, mountPoint);
							}
						}

						curMount->Release();
					}
				}
				mountId = iter->Next(&curChangeInstance);
			}

			iter->Release();
			startChangeInstance = nextChangeInstance;
		}
	}

	return 0;
}
	void MountOptionsDialog::OnOKButtonClick (wxCommandEvent& event)
	{	
		bool bUnsupportedKdf = false;
		TransferDataFromWindow();

		try
		{
			Options.Password = PasswordPanel->GetPassword();
		}
		catch (PasswordException& e)
		{
			Gui->ShowWarning (e);
			return;
		}
		Options.Pim = PasswordPanel->GetVolumePim();
		Options.Kdf = PasswordPanel->GetPkcs5Kdf(bUnsupportedKdf);
		if (bUnsupportedKdf)
		{
			Gui->ShowWarning (LangString ["ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"]);
			return;
		}
		Options.TrueCryptMode = PasswordPanel->GetTrueCryptMode();
		Options.Keyfiles = PasswordPanel->GetKeyfiles();

		if (ReadOnlyCheckBox->IsChecked())
		{
			Options.Protection = VolumeProtection::ReadOnly;
		}
		else if (ProtectionCheckBox->IsChecked())
		{
			try
			{
				Options.ProtectionPassword = ProtectionPasswordPanel->GetPassword();
			}
			catch (PasswordException& e)
			{
				Gui->ShowWarning (e);
				return;
			}
			Options.Protection = VolumeProtection::HiddenVolumeReadOnly;			
			Options.ProtectionPim = ProtectionPasswordPanel->GetVolumePim();
			Options.ProtectionKdf = ProtectionPasswordPanel->GetPkcs5Kdf(Options.TrueCryptMode, bUnsupportedKdf);
			if (bUnsupportedKdf)
			{
				Gui->ShowWarning (LangString ["ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"]);
				return;
			}
			Options.ProtectionKeyfiles = ProtectionPasswordPanel->GetKeyfiles();
		}
		else
		{
			Options.Protection = VolumeProtection::None;
		}

		wstring mountPoint (MountPointTextCtrl->GetValue());
		if (!mountPoint.empty())
			Options.MountPoint = make_shared <DirectoryPath> (mountPoint);

		Options.FilesystemOptions = FilesystemOptionsTextCtrl->GetValue();

		EndModal (wxID_OK);
	}