-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 | |||
@@ -1,391 +1,392 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> | 2 | ** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> |
3 | ** Copyright (C) Lorn Potter <llornkcor@handhelds.org> | 3 | ** Copyright (C) Lorn Potter <llornkcor@handhelds.org> |
4 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of Opie Environment. | 6 | ** This file is part of Opie Environment. |
7 | ** | 7 | ** |
8 | ** This file may be distributed and/or modified under the terms of the | 8 | ** This file may be distributed and/or modified under the terms of the |
9 | ** GNU General Public License version 2 as published by the Free Software | 9 | ** GNU General Public License version 2 as published by the Free Software |
10 | ** Foundation and appearing in the file LICENSE.GPL included in the | 10 | ** Foundation and appearing in the file LICENSE.GPL included in the |
11 | ** packaging of this file. | 11 | ** packaging of this file. |
12 | ** | 12 | ** |
13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
15 | ** | 15 | ** |
16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
17 | ** | 17 | ** |
18 | ** Contact info@trolltech.com if any conditions of this licensing are | 18 | ** Contact info@trolltech.com if any conditions of this licensing are |
19 | ** not clear to you. | 19 | ** not clear to you. |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #include <qpe/storage.h> | 23 | #include <qpe/storage.h> |
24 | 24 | ||
25 | #include <qcopchannel_qws.h> | 25 | #include <qcopchannel_qws.h> |
26 | 26 | ||
27 | #include <stdio.h> | 27 | #include <stdio.h> |
28 | 28 | ||
29 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 29 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
30 | #include <sys/vfs.h> | 30 | #include <sys/vfs.h> |
31 | #include <mntent.h> | 31 | #include <mntent.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #ifdef Q_OS_MACX | 34 | #ifdef Q_OS_MACX |
35 | # include <sys/param.h> | 35 | # include <sys/param.h> |
36 | # include <sys/ucred.h> | 36 | # include <sys/ucred.h> |
37 | # include <sys/mount.h> | 37 | # include <sys/mount.h> |
38 | # include <stdio.h> // For strerror() | 38 | # include <stdio.h> // For strerror() |
39 | # include <errno.h> | 39 | # include <errno.h> |
40 | #endif /* Q_OS_MACX */ | 40 | #endif /* Q_OS_MACX */ |
41 | 41 | ||
42 | 42 | ||
43 | // Shouldn't be here ! (eilers) | 43 | // Shouldn't be here ! (eilers) |
44 | // #include <sys/vfs.h> | 44 | // #include <sys/vfs.h> |
45 | // #include <mntent.h> | 45 | // #include <mntent.h> |
46 | 46 | ||
47 | 47 | ||
48 | static bool isCF(const QString& m) | 48 | static bool isCF(const QString& m) |
49 | { | 49 | { |
50 | 50 | ||
51 | #ifndef Q_OS_MACX | 51 | #ifndef Q_OS_MACX |
52 | FILE* f = fopen("/var/run/stab", "r"); | 52 | FILE* f = fopen("/var/run/stab", "r"); |
53 | if (!f) f = fopen("/var/state/pcmcia/stab", "r"); | 53 | if (!f) f = fopen("/var/state/pcmcia/stab", "r"); |
54 | if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); | 54 | if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); |
55 | if ( f ) | 55 | if ( f ) |
56 | { | 56 | { |
57 | char line[1024]; | 57 | char line[1024]; |
58 | char devtype[80]; | 58 | char devtype[80]; |
59 | char devname[80]; | 59 | char devname[80]; |
60 | while ( fgets( line, 1024, f ) ) | 60 | while ( fgets( line, 1024, f ) ) |
61 | { | 61 | { |
62 | // 0 ide ide-cs 0 hda 3 0 | 62 | // 0 ide ide-cs 0 hda 3 0 |
63 | if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) | 63 | if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) |
64 | { | 64 | { |
65 | if ( QString(devtype) == "ide" && m.find(devname)>0 ) | 65 | if ( QString(devtype) == "ide" && m.find(devname)>0 ) |
66 | { | 66 | { |
67 | fclose(f); | 67 | fclose(f); |
68 | return TRUE; | 68 | return TRUE; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | } | 71 | } |
72 | fclose(f); | 72 | fclose(f); |
73 | } | 73 | } |
74 | #endif /* Q_OS_MACX */ | 74 | #endif /* Q_OS_MACX */ |
75 | return FALSE; | 75 | return FALSE; |
76 | } | 76 | } |
77 | 77 | ||
78 | /*! \class StorageInfo storage.h | 78 | /*! \class StorageInfo storage.h |
79 | \brief The StorageInfo class describes the disks mounted on the file system. | 79 | \brief The StorageInfo class describes the disks mounted on the file system. |
80 | 80 | ||
81 | This class provides access to the mount information for the Linux | 81 | This class provides access to the mount information for the Linux |
82 | filesystem. Each mount point is represented by the FileSystem class. | 82 | filesystem. Each mount point is represented by the FileSystem class. |
83 | To ensure this class has the most up to date size information, call | 83 | To ensure this class has the most up to date size information, call |
84 | the update() method. Note that this will automatically be signaled | 84 | the update() method. Note that this will automatically be signaled |
85 | by the operating system when a disk has been mounted or unmounted. | 85 | by the operating system when a disk has been mounted or unmounted. |
86 | 86 | ||
87 | \ingroup qtopiaemb | 87 | \ingroup qtopiaemb |
88 | */ | 88 | */ |
89 | 89 | ||
90 | /*! Constructor that determines the current mount points of the filesystem. | 90 | /*! Constructor that determines the current mount points of the filesystem. |
91 | The standard \a parent parameters is passed on to QObject. | 91 | The standard \a parent parameters is passed on to QObject. |
92 | */ | 92 | */ |
93 | StorageInfo::StorageInfo( QObject *parent ) | 93 | StorageInfo::StorageInfo( QObject *parent ) |
94 | : QObject( parent ) | 94 | : QObject( parent ) |
95 | { | 95 | { |
96 | mFileSystems.setAutoDelete( TRUE ); | 96 | mFileSystems.setAutoDelete( TRUE ); |
97 | channel = new QCopChannel( "QPE/Card", this ); | 97 | channel = new QCopChannel( "QPE/Card", this ); |
98 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 98 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
99 | this, SLOT(cardMessage(const QCString&,const QByteArray&)) ); | 99 | this, SLOT(cardMessage(const QCString&,const QByteArray&)) ); |
100 | update(); | 100 | update(); |
101 | } | 101 | } |
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 | } |
248 | for( int i = 0; i < count; i++ ) | 249 | for( int i = 0; i < count; i++ ) |
249 | { | 250 | { |
250 | QString deviceName = mntbufp[i]->f_mntfromname; | 251 | QString deviceName = mntbufp[i]->f_mntfromname; |
251 | qDebug(deviceName); | 252 | qDebug(deviceName); |
252 | if( deviceName.left( name.length() ) == name ) | 253 | if( deviceName.left( name.length() ) == name ) |
253 | hasDevice = true; | 254 | hasDevice = true; |
254 | } | 255 | } |
255 | #else | 256 | #else |
256 | // Linux | 257 | // Linux |
257 | struct mntent *me; | 258 | struct mntent *me; |
258 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 259 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
259 | if ( mntfp ) | 260 | if ( mntfp ) |
260 | { | 261 | { |
261 | while ( (me = getmntent( mntfp )) != 0 ) | 262 | while ( (me = getmntent( mntfp )) != 0 ) |
262 | { | 263 | { |
263 | QString deviceName = me->mnt_fsname; | 264 | QString deviceName = me->mnt_fsname; |
264 | // qDebug(deviceName); | 265 | // qDebug(deviceName); |
265 | if( deviceName.left(name.length()) == name) | 266 | if( deviceName.left(name.length()) == name) |
266 | { | 267 | { |
267 | hasDevice = true; | 268 | hasDevice = true; |
268 | } | 269 | } |
269 | } | 270 | } |
270 | } | 271 | } |
271 | endmntent( mntfp ); | 272 | endmntent( mntfp ); |
272 | #endif /* Q_OS_MACX */ | 273 | #endif /* Q_OS_MACX */ |
273 | 274 | ||
274 | 275 | ||
275 | return hasDevice; | 276 | return hasDevice; |
276 | } | 277 | } |
277 | 278 | ||
278 | /*! | 279 | /*! |
279 | * @fn static bool StorageInfo::hasCf() | 280 | * @fn static bool StorageInfo::hasCf() |
280 | * @brief returns whether device has Cf mounted | 281 | * @brief returns whether device has Cf mounted |
281 | * | 282 | * |
282 | */ | 283 | */ |
283 | bool StorageInfo::hasCf() | 284 | bool StorageInfo::hasCf() |
284 | { | 285 | { |
285 | return deviceTab("/dev/hd"); | 286 | return deviceTab("/dev/hd"); |
286 | } | 287 | } |
287 | 288 | ||
288 | /*! | 289 | /*! |
289 | * @fn static bool StorageInfo::hasSd() | 290 | * @fn static bool StorageInfo::hasSd() |
290 | * @brief returns whether device has SD mounted | 291 | * @brief returns whether device has SD mounted |
291 | * | 292 | * |
292 | */ | 293 | */ |
293 | bool StorageInfo::hasSd() | 294 | bool StorageInfo::hasSd() |
294 | { | 295 | { |
295 | return deviceTab("/dev/mmcd"); | 296 | return deviceTab("/dev/mmcd"); |
296 | } | 297 | } |
297 | 298 | ||
298 | /*! | 299 | /*! |
299 | * @fn static bool StorageInfo::hasMmc() | 300 | * @fn static bool StorageInfo::hasMmc() |
300 | * @brief returns whether device has mmc mounted | 301 | * @brief returns whether device has mmc mounted |
301 | * | 302 | * |
302 | */ | 303 | */ |
303 | bool StorageInfo::hasMmc() | 304 | bool StorageInfo::hasMmc() |
304 | { | 305 | { |
305 | bool hasMmc=false; | 306 | bool hasMmc=false; |
306 | if( deviceTab("/dev/mmc/part")) | 307 | if( deviceTab("/dev/mmc/part")) |
307 | hasMmc=true; | 308 | hasMmc=true; |
308 | if( deviceTab("/dev/mmcd")) | 309 | if( deviceTab("/dev/mmcd")) |
309 | hasMmc=true; | 310 | hasMmc=true; |
310 | return hasMmc; | 311 | return hasMmc; |
311 | } | 312 | } |
312 | 313 | ||
313 | /*! \fn const QList<FileSystem> &StorageInfo::fileSystems() const | 314 | /*! \fn const QList<FileSystem> &StorageInfo::fileSystems() const |
314 | Returns a list of all available mounted file systems. | 315 | Returns a list of all available mounted file systems. |
315 | 316 | ||
316 | \warning This may change in Qtopia 3.x to return only relevant Qtopia file systems (and ignore mount points such as /tmp) | 317 | \warning This may change in Qtopia 3.x to return only relevant Qtopia file systems (and ignore mount points such as /tmp) |
317 | */ | 318 | */ |
318 | 319 | ||
319 | /*! \fn void StorageInfo::disksChanged() | 320 | /*! \fn void StorageInfo::disksChanged() |
320 | Gets emitted when a disk has been mounted or unmounted, such as when | 321 | Gets emitted when a disk has been mounted or unmounted, such as when |
321 | a CF c | 322 | a CF c |
322 | */ | 323 | */ |
323 | //--------------------------------------------------------------------------- | 324 | //--------------------------------------------------------------------------- |
324 | 325 | ||
325 | FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) | 326 | FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) |
326 | : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) | 327 | : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) |
327 | { | 328 | { |
328 | update(); | 329 | update(); |
329 | } | 330 | } |
330 | 331 | ||
331 | void FileSystem::update() | 332 | void FileSystem::update() |
332 | { | 333 | { |
333 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 334 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
334 | struct statfs fs; | 335 | struct statfs fs; |
335 | if ( !statfs( fspath.latin1(), &fs ) ) | 336 | if ( !statfs( fspath.latin1(), &fs ) ) |
336 | { | 337 | { |
337 | blkSize = fs.f_bsize; | 338 | blkSize = fs.f_bsize; |
338 | totalBlks = fs.f_blocks; | 339 | totalBlks = fs.f_blocks; |
339 | availBlks = fs.f_bavail; | 340 | availBlks = fs.f_bavail; |
340 | } | 341 | } |
341 | else | 342 | else |
342 | { | 343 | { |
343 | blkSize = 0; | 344 | blkSize = 0; |
344 | totalBlks = 0; | 345 | totalBlks = 0; |
345 | availBlks = 0; | 346 | availBlks = 0; |
346 | } | 347 | } |
347 | #endif | 348 | #endif |
348 | } | 349 | } |
349 | 350 | ||
350 | /*! \class FileSystem storage.h | 351 | /*! \class FileSystem storage.h |
351 | \brief The FileSystem class describes a single mount point. | 352 | \brief The FileSystem class describes a single mount point. |
352 | 353 | ||
353 | This class simply returns information about a mount point, including | 354 | This class simply returns information about a mount point, including |
354 | file system name, mount point, human readable name, size information | 355 | file system name, mount point, human readable name, size information |
355 | and mount options information. | 356 | and mount options information. |
356 | \ingroup qtopiaemb | 357 | \ingroup qtopiaemb |
357 | 358 | ||
358 | \sa StorageInfo | 359 | \sa StorageInfo |
359 | */ | 360 | */ |
360 | 361 | ||
361 | /*! \fn const QString &FileSystem::disk() const | 362 | /*! \fn const QString &FileSystem::disk() const |
362 | Returns the file system name, such as /dev/hda3 | 363 | Returns the file system name, such as /dev/hda3 |
363 | */ | 364 | */ |
364 | 365 | ||
365 | /*! \fn const QString &FileSystem::path() const | 366 | /*! \fn const QString &FileSystem::path() const |
366 | Returns the mount path, such as /home | 367 | Returns the mount path, such as /home |
367 | */ | 368 | */ |
368 | 369 | ||
369 | /*! \fn const QString &FileSystem::name() const | 370 | /*! \fn const QString &FileSystem::name() const |
370 | Returns the translated, human readable name for the mount directory. | 371 | Returns the translated, human readable name for the mount directory. |
371 | */ | 372 | */ |
372 | 373 | ||
373 | /*! \fn const QString &FileSystem::options() const | 374 | /*! \fn const QString &FileSystem::options() const |
374 | Returns the mount options | 375 | Returns the mount options |
375 | */ | 376 | */ |
376 | 377 | ||
377 | /*! \fn long FileSystem::blockSize() const | 378 | /*! \fn long FileSystem::blockSize() const |
378 | Returns the size of each block on the file system. | 379 | Returns the size of each block on the file system. |
379 | */ | 380 | */ |
380 | 381 | ||
381 | /*! \fn long FileSystem::totalBlocks() const | 382 | /*! \fn long FileSystem::totalBlocks() const |
382 | Returns the total number of blocks on the file system | 383 | Returns the total number of blocks on the file system |
383 | */ | 384 | */ |
384 | 385 | ||
385 | /*! \fn long FileSystem::availBlocks() const | 386 | /*! \fn long FileSystem::availBlocks() const |
386 | Returns the number of available blocks on the file system | 387 | Returns the number of available blocks on the file system |
387 | */ | 388 | */ |
388 | 389 | ||
389 | /*! \fn bool FileSystem::isRemovable() const | 390 | /*! \fn bool FileSystem::isRemovable() const |
390 | Returns flag whether the file system can be removed, such as a CF card | 391 | Returns flag whether the file system can be removed, such as a CF card |
391 | would be removable, but the internal memory wouldn't | 392 | would be removable, but the internal memory wouldn't |