By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release. View | Details | Raw Unified | Return to bug 1708
Collapse All | Expand All

(-)a/tdecore/tdehw/tdestoragedevice.cpp (-50 / +195 lines)
Lines 32-37 Link Here
32
#include "tdeglobal.h" 
32
#include "tdeglobal.h" 
33
#include "kiconloader.h" 
33
#include "kiconloader.h" 
34
#include "tdetempfile.h" 
34
#include "tdetempfile.h" 
35
#include "kstandarddirs.h"
35
36
36
#include "tdehardwaredevices.h" 
37
#include "tdehardwaredevices.h" 
37
38
Lines 601-661 TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption Link Here
601
602
602
	TQString ret = mountPath();
603
	TQString ret = mountPath();
603
604
605
	// Device is already mounted
604
	if (!ret.isNull()) {
606
	if (!ret.isNull()) {
605
		return ret;
607
		return ret;
606
	}
608
	}
607
609
608
	// Create dummy password file
610
	TQString command;
609
	KTempFile passwordFile(TQString::null, "tmp", 0600);
611
	TQString devNode = deviceNode();
610
	passwordFile.setAutoDelete(true);
612
	devNode.replace("'", "'\\''");
613
	mediaName.replace("'", "'\\''");
611
614
615
#if defined(WITH_UDISKS2) || defined(WITH_UDISKS)
616
	// Prepare filesystem options for mount
612
	TQString optionString;
617
	TQString optionString;
618
613
	if (mountOptions["ro"] == "true") {
619
	if (mountOptions["ro"] == "true") {
614
		optionString.append(" -r");
620
		optionString.append(",ro");
615
	}
621
	}
616
	
622
617
	if (mountOptions["atime"] != "true") {
623
	if (mountOptions["atime"] != "true") {
618
		optionString.append(" -A");
624
		optionString.append(",noatime");
619
	}
620
	
621
	if (mountOptions["utf8"] == "true") {
622
		optionString.append(" -c utf8");
623
	}
625
	}
624
	
626
625
	if (mountOptions["sync"] == "true") {
627
	if (mountOptions["sync"] == "true") {
626
		optionString.append(" -s");
628
		optionString.append(",sync");
627
	}
629
	}
628
630
629
	if (mountOptions.contains("filesystem")) {
631
	if(  (mountOptions["filesystem"] == "fat")
630
		optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"]));
632
	  || (mountOptions["filesystem"] == "vfat")
633
	  || (mountOptions["filesystem"] == "msdos")
634
	  || (mountOptions["filesystem"] == "umsdos")
635
	) {
636
		if (mountOptions.contains("shortname")) {
637
			optionString.append(TQString(",shortname=%1").arg(mountOptions["shortname"]));
638
		}
631
	}
639
	}
632
640
633
	if (mountOptions.contains("locale")) {
641
	if(  (mountOptions["filesystem"] == "iso9660")
634
		optionString.append(TQString(" -c %1").arg(mountOptions["locale"]));
642
	  || (mountOptions["filesystem"] == "ntfs")
643
	  || (mountOptions["filesystem"] == "jfs")
644
	) {
645
		if (mountOptions["utf8"] == "true") {
646
			optionString.append(",iocharset=utf8");
647
		}
635
	}
648
	}
636
649
637
	TQString passFileName = passwordFile.name();
650
	if( (mountOptions["filesystem"] == "ntfs-3g") ) {
638
	TQString devNode = deviceNode();
651
		if (mountOptions.contains("locale")) {
639
	passFileName.replace("'", "'\\''");
652
			optionString.append(TQString(",locale=%1").arg(mountOptions["locale"]));
640
	devNode.replace("'", "'\\''");
653
		}
641
	mediaName.replace("'", "'\\''");
654
	}
642
	TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName);
643
655
644
	FILE *exepipe = popen(command.ascii(), "r");
656
	if(  (mountOptions["filesystem"] == "ext3")
645
	if (exepipe) {
657
	  || (mountOptions["filesystem"] == "ext4")
646
		TQString pmount_output;
658
	) {
647
		char buffer[8092];
659
		if (mountOptions.contains("journaling")) {
648
		pmount_output = fgets(buffer, sizeof(buffer), exepipe);
660
			optionString.append(TQString(",data=%1").arg(mountOptions["journaling"]));
649
		*retcode = pclose(exepipe);
650
		if (errRet) {
651
			*errRet = pmount_output;
652
		}
661
		}
653
	}
662
	}
654
663
655
	// Update internal mount data
664
	if (!optionString.isEmpty()) {
656
	TDEGlobal::hardwareDevices()->processModifiedMounts();
665
		optionString.remove(0, 1);
666
	}
667
#endif // defined(WITH_UDISKS2) || defined(WITH_UDISKS)
657
668
658
	ret = mountPath();
669
#ifdef WITH_UDISKS2
670
	if(command.isEmpty()) {
671
		// Use 'udisksctl' command (from UDISKS2), if available
672
		TQString udisksctlProg = TDEGlobal::dirs()->findExe("udisksctl");
673
		if (!udisksctlProg.isEmpty()) {
674
675
			if(!optionString.isEmpty()) {
676
				optionString.insert(0, "-o ");
677
			}
678
679
			if (mountOptions.contains("filesystem")) {
680
				optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"]));
681
			}
682
683
			command = TQString("udisksctl mount -b '%1' %2 2>&1").arg(devNode).arg(optionString);
684
		}
685
	}
686
#endif // WITH_UDISKS2
687
688
#ifdef WITH_UDISKS
689
	if(command.isEmpty()) {
690
		// Use 'udisks' command (from UDISKS1), if available
691
		TQString udisksProg = TDEGlobal::dirs()->findExe("udisks");
692
		if (!udisksProg.isEmpty()) {
693
			TQString optionString;
694
695
			if(!optionString.isEmpty()) {
696
				optionString.insert(0, "--mount-options ");
697
			}
698
699
			if (mountOptions.contains("filesystem")) {
700
				optionString.append(TQString(" --mount-fstype %1").arg(mountOptions["filesystem"]));
701
			}
702
703
			if (mountOptions["utf8"] == "true") {
704
				if(  (mountOptions["filesystem"] == "fat")
705
				  || (mountOptions["filesystem"] == "vfat")
706
				  || (mountOptions["filesystem"] == "msdos")
707
				  || (mountOptions["filesystem"] == "umsdos")
708
				) {
709
					/* VFAT and UTF-8 need special care, see Debian bug #443514 and mount(1) */
710
					optionString.append(",utf8,iocharset=iso8859-1");
711
				}
712
713
				if(  (mountOptions["filesystem"] == "iso9660")
714
				  || (mountOptions["filesystem"] == "ntfs")
715
				) {
716
					optionString.append(",utf8");
717
				}
718
			}
719
720
			command = TQString("udisks --mount '%1' %2 2>&1").arg(devNode).arg(optionString);
721
		}
722
	}
723
#endif // WITH_UDISKS
724
725
	if(command.isEmpty()) {
726
		// Use 'pmount' command, if available
727
		TQString pmountProg = TDEGlobal::dirs()->findExe("pmount");
728
		if (!pmountProg.isEmpty()) {
729
			// Create dummy password file
730
			KTempFile passwordFile(TQString::null, "tmp", 0600);
731
			passwordFile.setAutoDelete(true);
732
733
			TQString optionString;
734
			if (mountOptions["ro"] == "true") {
735
				optionString.append(" -r");
736
			}
737
738
			if (mountOptions["atime"] != "true") {
739
				optionString.append(" -A");
740
			}
741
742
			if (mountOptions["utf8"] == "true") {
743
				optionString.append(" -c utf8");
744
			}
745
746
			if (mountOptions["sync"] == "true") {
747
				optionString.append(" -s");
748
			}
749
750
			if (mountOptions.contains("filesystem")) {
751
				optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"]));
752
			}
753
754
			if (mountOptions.contains("locale")) {
755
				optionString.append(TQString(" -c %1").arg(mountOptions["locale"]));
756
			}
757
758
			TQString passFileName = passwordFile.name();
759
			passFileName.replace("'", "'\\''");
760
761
			command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName);
762
		}
763
	}
764
765
	if(!command.isEmpty()) {
766
		FILE *exepipe = popen(command.local8Bit(), "r");
767
		if (exepipe) {
768
			TQString pmount_output;
769
			char buffer[8092];
770
			pmount_output = fgets(buffer, sizeof(buffer), exepipe);
771
			*retcode = pclose(exepipe);
772
			if (errRet) {
773
				*errRet = pmount_output;
774
			}
775
		}
776
777
		// Update internal mount data
778
		TDEGlobal::hardwareDevices()->processModifiedMounts();
779
780
		ret = mountPath();
781
	}
659
782
660
	return ret;
783
	return ret;
661
}
784
}
Lines 715-721 TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString me Link Here
715
	mediaName.replace("'", "'\\''");
826
	mediaName.replace("'", "'\\''");
716
	TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName);
827
	TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName);
717
828
718
	FILE *exepipe = popen(command.ascii(), "r");
829
	FILE *exepipe = popen(command.local8Bit(), "r");
719
	if (exepipe) {
830
	if (exepipe) {
720
		TQString pmount_output;
831
		TQString pmount_output;
721
		char buffer[8092];
832
		char buffer[8092];
Lines 741-771 bool TDEStorageDevice::unmountDevice(TQString* errRet, int* retcode) { Link Here
741
	}
852
	}
742
853
743
	TQString mountpoint = mountPath();
854
	TQString mountpoint = mountPath();
855
	TQString devNode = deviceNode();
744
856
745
	if (mountpoint.isNull()) {
857
	if (mountpoint.isNull()) {
746
		return true;
858
		return true;
747
	}
859
	}
748
860
749
	mountpoint.replace("'", "'\\''");
861
	mountpoint.replace("'", "'\\''");
750
	TQString command = TQString("pumount '%1' 2>&1").arg(mountpoint);
862
751
	FILE *exepipe = popen(command.ascii(), "r");
863
	TQString command;
752
	if (exepipe) {
864
753
		TQString pmount_output;
865
#ifdef WITH_UDISKS2
754
		char buffer[8092];
866
	if(command.isEmpty() &&
755
		pmount_output = fgets(buffer, sizeof(buffer), exepipe);
867
	   !(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) {
756
		*retcode = pclose(exepipe);
868
		command = TQString("udisksctl unmount -b '%1' 2>&1").arg(devNode);
757
		if (*retcode == 0) {
869
	}
758
			return true;
870
#endif // WITH_UDISKS2
759
		}
871
#ifdef WITH_UDISKS
760
		else {
872
	if(command.isEmpty() &&
761
			if (errRet) {
873
	   !(TDEGlobal::dirs()->findExe("udisks").isEmpty()) ) {
762
				*errRet = pmount_output;
874
		command = TQString("udisks --unmount '%1' 2>&1").arg(devNode);
875
	}
876
#endif // WITH_UDISKS
877
	if(command.isEmpty() &&
878
	   !(TDEGlobal::dirs()->findExe("pumount").isEmpty())) {
879
		command = TQString("pumount '%1' 2>&1").arg(mountpoint);
880
	}
881
882
	if(!command.isEmpty()) {
883
		FILE *exepipe = popen(command.local8Bit(), "r");
884
		if (exepipe) {
885
			TQString pmount_output;
886
			char buffer[8092];
887
			pmount_output = fgets(buffer, sizeof(buffer), exepipe);
888
			*retcode = pclose(exepipe);
889
			if (*retcode == 0) {
890
				return true;
891
			}
892
			else {
893
				if (errRet) {
894
					*errRet = pmount_output;
895
				}
763
			}
896
			}
764
		}
897
		}
765
	}
766
898
767
	// Update internal mount data
899
		// Update internal mount data
768
	TDEGlobal::hardwareDevices()->processModifiedMounts();
900
		TDEGlobal::hardwareDevices()->processModifiedMounts();
901
	}
769
902
770
	return false;
903
	return false;
771
}
904
}

Return to bug 1708