author | alwin <alwin> | 2005-03-03 22:38:59 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-03 22:38:59 (UTC) |
commit | e007cb2e4e3627ece4a093bc976debd6366ed1fa (patch) (unidiff) | |
tree | cdc8f70802fc167f698dcc647d048c4bac332878 /library | |
parent | 98af15f829dadf9083e5e897328ab58e5e82a0fd (diff) | |
download | opie-e007cb2e4e3627ece4a093bc976debd6366ed1fa.zip opie-e007cb2e4e3627ece4a093bc976debd6366ed1fa.tar.gz opie-e007cb2e4e3627ece4a093bc976debd6366ed1fa.tar.bz2 |
added device names for 2.6 kernel
-rw-r--r-- | library/storage.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/library/storage.cpp b/library/storage.cpp index fcee689..9549ff3 100644 --- a/library/storage.cpp +++ b/library/storage.cpp | |||
@@ -102,146 +102,147 @@ StorageInfo::StorageInfo( QObject *parent ) | |||
102 | 102 | ||
103 | /*! Returns the longest matching FileSystem that starts with the | 103 | /*! Returns the longest matching FileSystem that starts with the |
104 | same prefix as \a filename as its mount point. | 104 | same prefix as \a filename as its mount point. |
105 | */ | 105 | */ |
106 | const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) | 106 | const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) |
107 | { | 107 | { |
108 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) | 108 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) |
109 | { | 109 | { |
110 | if ( filename.startsWith( (*i)->path() ) ) | 110 | if ( filename.startsWith( (*i)->path() ) ) |
111 | return (*i); | 111 | return (*i); |
112 | } | 112 | } |
113 | return 0; | 113 | return 0; |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) | 117 | void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) |
118 | { | 118 | { |
119 | if ( msg == "mtabChanged()" ) | 119 | if ( msg == "mtabChanged()" ) |
120 | update(); | 120 | update(); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | /*! Updates the mount and free space available information for each mount | 124 | /*! Updates the mount and free space available information for each mount |
125 | point. This method is automatically called when a disk is mounted or | 125 | point. This method is automatically called when a disk is mounted or |
126 | unmounted. | 126 | unmounted. |
127 | */ | 127 | */ |
128 | // cause of the lack of a d pointer we need | 128 | // cause of the lack of a d pointer we need |
129 | // to store informations in a config file :( | 129 | // to store informations in a config file :( |
130 | void StorageInfo::update() | 130 | void StorageInfo::update() |
131 | { | 131 | { |
132 | //qDebug("StorageInfo::updating"); | 132 | //qDebug("StorageInfo::updating"); |
133 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 133 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
134 | struct mntent *me; | 134 | struct mntent *me; |
135 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 135 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
136 | 136 | ||
137 | QStringList curdisks; | 137 | QStringList curdisks; |
138 | QStringList curopts; | 138 | QStringList curopts; |
139 | QStringList curfs; | 139 | QStringList curfs; |
140 | bool rebuild = FALSE; | 140 | bool rebuild = FALSE; |
141 | int n=0; | 141 | int n=0; |
142 | if ( mntfp ) | 142 | if ( mntfp ) |
143 | { | 143 | { |
144 | while ( (me = getmntent( mntfp )) != 0 ) | 144 | while ( (me = getmntent( mntfp )) != 0 ) |
145 | { | 145 | { |
146 | QString fs = me->mnt_fsname; | 146 | QString fs = me->mnt_fsname; |
147 | if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" | 147 | if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" |
148 | || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" | 148 | || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" |
149 | || fs.left( 14 ) == "/dev/mmc/part1" | 149 | || fs.left( 14 ) == "/dev/mmc/part1" |
150 | || fs.left(5)=="tmpfs" || fs.left(9)=="/dev/root" ) | 150 | || fs.left(5)=="tmpfs" || fs.left(11)=="/dev/mmcblk" |
151 | || fs.left(9)=="/dev/root" ) | ||
151 | { | 152 | { |
152 | n++; | 153 | n++; |
153 | curdisks.append(fs); | 154 | curdisks.append(fs); |
154 | curopts.append( me->mnt_opts ); | 155 | curopts.append( me->mnt_opts ); |
155 | //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); | 156 | //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); |
156 | curfs.append( me->mnt_dir ); | 157 | curfs.append( me->mnt_dir ); |
157 | bool found = FALSE; | 158 | bool found = FALSE; |
158 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) | 159 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) |
159 | { | 160 | { |
160 | if ( (*i)->disk() == fs ) | 161 | if ( (*i)->disk() == fs ) |
161 | { | 162 | { |
162 | found = TRUE; | 163 | found = TRUE; |
163 | break; | 164 | break; |
164 | } | 165 | } |
165 | } | 166 | } |
166 | if ( !found ) | 167 | if ( !found ) |
167 | rebuild = TRUE; | 168 | rebuild = TRUE; |
168 | } | 169 | } |
169 | } | 170 | } |
170 | endmntent( mntfp ); | 171 | endmntent( mntfp ); |
171 | } | 172 | } |
172 | if ( rebuild || n != (int)mFileSystems.count() ) | 173 | if ( rebuild || n != (int)mFileSystems.count() ) |
173 | { | 174 | { |
174 | mFileSystems.clear(); | 175 | mFileSystems.clear(); |
175 | QStringList::ConstIterator it=curdisks.begin(); | 176 | QStringList::ConstIterator it=curdisks.begin(); |
176 | QStringList::ConstIterator fsit=curfs.begin(); | 177 | QStringList::ConstIterator fsit=curfs.begin(); |
177 | QStringList::ConstIterator optsIt=curopts.begin(); | 178 | QStringList::ConstIterator optsIt=curopts.begin(); |
178 | for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) | 179 | for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) |
179 | { | 180 | { |
180 | QString opts = *optsIt; | 181 | QString opts = *optsIt; |
181 | 182 | ||
182 | QString disk = *it; | 183 | QString disk = *it; |
183 | QString humanname; | 184 | QString humanname; |
184 | bool removable = FALSE; | 185 | bool removable = FALSE; |
185 | if ( isCF(disk) ) | 186 | if ( isCF(disk) ) |
186 | { | 187 | { |
187 | humanname = tr("CF Card"); | 188 | humanname = tr("CF Card"); |
188 | removable = TRUE; | 189 | removable = TRUE; |
189 | } | 190 | } |
190 | else if ( disk == "/dev/hda1" ) | 191 | else if ( disk == "/dev/hda1" ) |
191 | { | 192 | { |
192 | humanname = tr("Hard Disk"); | 193 | humanname = tr("Hard Disk"); |
193 | } | 194 | } |
194 | else if ( disk.left(9) == "/dev/mmcd" ) | 195 | else if ( disk.left(9) == "/dev/mmcd" ) |
195 | { | 196 | { |
196 | humanname = tr("SD Card"); | 197 | humanname = tr("SD Card"); |
197 | removable = TRUE; | 198 | removable = TRUE; |
198 | } | 199 | } |
199 | else if ( disk.left( 14 ) == "/dev/mmc/part1" ) | 200 | else if ( disk.left( 14 ) == "/dev/mmc/part1" || disk.left(11) == "/dev/mmcblk" ) |
200 | { | 201 | { |
201 | humanname = tr("MMC Card"); | 202 | humanname = tr("MMC Card"); |
202 | removable = TRUE; | 203 | removable = TRUE; |
203 | } | 204 | } |
204 | else if ( disk.left(7) == "/dev/hd" ) | 205 | else if ( disk.left(7) == "/dev/hd" ) |
205 | humanname = tr("Hard Disk") + " " + disk; | 206 | humanname = tr("Hard Disk") + " " + disk; |
206 | else if ( disk.left(7) == "/dev/sd" ) | 207 | else if ( disk.left(7) == "/dev/sd" ) |
207 | humanname = tr("SCSI Hard Disk") + " " + disk; | 208 | humanname = tr("SCSI Hard Disk") + " " + disk; |
208 | else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs | 209 | else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs |
209 | humanname = tr("Internal Memory"); | 210 | humanname = tr("Internal Memory"); |
210 | else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) | 211 | else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) |
211 | humanname = tr("Internal Storage"); | 212 | humanname = tr("Internal Storage"); |
212 | else if ( disk.left(14) == "/dev/mtdblock/" ) | 213 | else if ( disk.left(14) == "/dev/mtdblock/" ) |
213 | humanname = tr("Internal Storage") + " " + disk; | 214 | humanname = tr("Internal Storage") + " " + disk; |
214 | else if ( disk.left(13) == "/dev/mtdblock" ) | 215 | else if ( disk.left(13) == "/dev/mtdblock" ) |
215 | humanname = tr("Internal Storage") + " " + disk; | 216 | humanname = tr("Internal Storage") + " " + disk; |
216 | else if ( disk.left(9) == "/dev/root" ) | 217 | else if ( disk.left(9) == "/dev/root" ) |
217 | humanname = tr("Internal Storage") + " " + disk; | 218 | humanname = tr("Internal Storage") + " " + disk; |
218 | else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs | 219 | else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs |
219 | humanname = tr("Internal Memory"); | 220 | humanname = tr("Internal Memory"); |
220 | FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); | 221 | FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); |
221 | mFileSystems.append( fs ); | 222 | mFileSystems.append( fs ); |
222 | } | 223 | } |
223 | emit disksChanged(); | 224 | emit disksChanged(); |
224 | } | 225 | } |
225 | else | 226 | else |
226 | { | 227 | { |
227 | // just update them | 228 | // just update them |
228 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) | 229 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) |
229 | i.current()->update(); | 230 | i.current()->update(); |
230 | } | 231 | } |
231 | #endif | 232 | #endif |
232 | } | 233 | } |
233 | 234 | ||
234 | bool deviceTab( const char *device) | 235 | bool deviceTab( const char *device) |
235 | { | 236 | { |
236 | QString name = device; | 237 | QString name = device; |
237 | bool hasDevice=false; | 238 | bool hasDevice=false; |
238 | 239 | ||
239 | #ifdef Q_OS_MACX | 240 | #ifdef Q_OS_MACX |
240 | // Darwin (MacOS X) | 241 | // Darwin (MacOS X) |
241 | struct statfs** mntbufp; | 242 | struct statfs** mntbufp; |
242 | int count = 0; | 243 | int count = 0; |
243 | if ( ( count = getmntinfo( mntbufp, MNT_WAIT ) ) == 0 ) | 244 | if ( ( count = getmntinfo( mntbufp, MNT_WAIT ) ) == 0 ) |
244 | { | 245 | { |
245 | qWarning("deviceTab: Error in getmntinfo(): %s",strerror( errno ) ); | 246 | qWarning("deviceTab: Error in getmntinfo(): %s",strerror( errno ) ); |
246 | hasDevice = false; | 247 | hasDevice = false; |
247 | } | 248 | } |