14 |
14 |
15 AbstractOperatingSystem subclass:#UnixOperatingSystem |
15 AbstractOperatingSystem subclass:#UnixOperatingSystem |
16 instanceVariableNames:'' |
16 instanceVariableNames:'' |
17 classVariableNames:'HostName DomainName SlowFork ForkFailed CurrentDirectory |
17 classVariableNames:'HostName DomainName SlowFork ForkFailed CurrentDirectory |
18 LastTimeInfo LastTimeInfoSeconds LastTimeInfoMilliseconds |
18 LastTimeInfo LastTimeInfoSeconds LastTimeInfoMilliseconds |
19 LastTimeInfoIsLocal' |
19 LastTimeInfoIsLocal CachedMountPoints CacheMountPointsTimeStamp' |
20 poolDictionaries:'' |
20 poolDictionaries:'' |
21 category:'OS-Unix' |
21 category:'OS-Unix' |
22 ! |
22 ! |
23 |
23 |
24 Object subclass:#FileDescriptorHandle |
24 Object subclass:#FileDescriptorHandle |
4822 OperatingSystem linkInfoOf:'resources/motif.style' |
4822 OperatingSystem linkInfoOf:'resources/motif.style' |
4823 " |
4823 " |
4824 ! |
4824 ! |
4825 |
4825 |
4826 mountPoints |
4826 mountPoints |
|
4827 "return a collection of mountPoints (aka. topDirectories of mounted file systems). |
|
4828 As this might be expensive on some systems, |
|
4829 the info is cached for some time (5 minutes)" |
|
4830 |
|
4831 CacheMountPointsTimeStamp notNil ifTrue:[ |
|
4832 AbsoluteTime now > (CacheMountPointsTimeStamp addSeconds:5*60) ifTrue:[ |
|
4833 CacheMountPointsTimeStamp := CachedMountPoints := nil. |
|
4834 ]. |
|
4835 ]. |
|
4836 CachedMountPoints notNil ifTrue:[ ^ CachedMountPoints ]. |
|
4837 |
|
4838 '/proc/mounts' asFilename exists ifTrue:[ |
|
4839 CachedMountPoints := self mountPointsFromProcFS. |
|
4840 CacheMountPointsTimeStamp := AbsoluteTime now. |
|
4841 ^ CachedMountPoints |
|
4842 ]. |
|
4843 |
|
4844 "/ TODO: add fallback code for other OS's (i.e. reading /etc/mtab) |
|
4845 ^ #() |
|
4846 |
|
4847 " |
|
4848 OperatingSystem mountPoints |
|
4849 " |
|
4850 ! |
|
4851 |
|
4852 mountPointsFromProcFS |
4827 "return a collection of mountPoints (aka. topDirectories of mounted file systems)" |
4853 "return a collection of mountPoints (aka. topDirectories of mounted file systems)" |
4828 |
4854 |
4829 |procFS entries| |
4855 |entries| |
4830 |
|
4831 procFS := '/proc/mounts' asFilename. |
|
4832 procFS exists ifFalse:[ |
|
4833 "/ TODO: add fallback code for other OS's |
|
4834 ^ #() |
|
4835 ]. |
|
4836 |
4856 |
4837 entries := OrderedCollection new. |
4857 entries := OrderedCollection new. |
4838 procFS readingLinesDo:[:eachLine | |
4858 ('/proc/mounts' asFilename) readingLinesDo:[:eachLine | |
4839 |items mountInfo| |
4859 |items mountInfo| |
4840 |
4860 |
4841 items := eachLine asCollectionOfWords. |
4861 items := eachLine asCollectionOfWords. |
4842 mountInfo := (MountInfo new |
4862 mountInfo := (MountInfo new |
4843 mountPointPath:(items at:2) |
4863 mountPointPath:(items at:2) |
4844 deviceOrRemotePath:(items at:1) |
4864 deviceOrRemotePath:(items at:1) |
4845 fsType:(items at:3) |
4865 fsType:(items at:3) |
4846 attributeString:(items at:4)). |
4866 attributeString:(items at:4)). |
4847 entries add:mountInfo |
4867 entries add:mountInfo |
4848 ]. |
4868 ]. |
4849 ^ entries |
4869 ^ entries |
4850 |
4870 |
4851 " |
4871 " |
4852 OperatingSystem mountPoints |
4872 OperatingSystem mountPointsFromProcFS |
4853 " |
4873 " |
4854 ! |
4874 ! |
4855 |
4875 |
4856 parentDirectoryName |
4876 parentDirectoryName |
4857 "return the name used to refer to parent directories. |
4877 "return the name used to refer to parent directories. |