@@ -121,35 +121,36 @@ static void detectName(FFDisk* disk, const FFstrbuf* device)
121121
122122#ifdef __ANDROID__
123123
124- static void detectType (const FFlist * allDisks , FFDisk * currentDisk , const char * options )
124+ static void detectType (const FFlist * devices , FFDisk * currentDisk , const char * options )
125125{
126- if (ffStrbufEqualS (& disk -> mountpoint , "/" ) || ffStrbufEqualS (& disk -> mountpoint , "/storage/emulated" ))
127- disk -> type = FF_DISK_TYPE_REGULAR ;
126+ if (ffStrbufEqualS (& currentDisk -> mountpoint , "/" ) || ffStrbufEqualS (& currentDisk -> mountpoint , "/storage/emulated" ))
127+ currentDisk -> type = FF_DISK_TYPE_REGULAR ;
128128 else if (ffStrbufStartsWithS (& disk -> mountpoint , "/mnt/media_rw/" ))
129- disk -> type = FF_DISK_TYPE_EXTERNAL ;
129+ currentDisk -> type = FF_DISK_TYPE_EXTERNAL ;
130130 else
131- disk -> type = FF_DISK_TYPE_HIDDEN ;
131+ currentDisk -> type = FF_DISK_TYPE_HIDDEN ;
132132}
133133
134134#else
135135
136- static bool isSubvolume (const FFlist * allDisks , const FFDisk * currentDisk )
136+ static bool isSubvolume (const FFlist * devices )
137137{
138- FF_LIST_FOR_EACH (FFDisk , disk , * allDisks )
138+ const FFstrbuf * currentDevie = ffListGet (devices , devices -> length - 1 );
139+
140+ for (uint32_t i = 0 ; i < devices -> length - 1 ; i ++ )
139141 {
140- if (disk == currentDisk )
141- continue ;
142+ const FFstrbuf * otherDevice = ffListGet (devices , i );
142143
143- if (ffStrbufEqual (& disk -> mountpoint , & currentDisk -> mountpoint ))
144+ if (ffStrbufEqual (currentDevie , otherDevice ))
144145 return true;
145146 }
146147
147148 return false;
148149}
149150
150- static void detectType (const FFlist * allDisks , FFDisk * currentDisk , const char * options )
151+ static void detectType (const FFlist * devices , FFDisk * currentDisk , const char * options )
151152{
152- if (isSubvolume (allDisks , currentDisk ))
153+ if (isSubvolume (devices ))
153154 currentDisk -> type = FF_DISK_TYPE_SUBVOLUME ;
154155 else if (strstr (options , "nosuid" ) != NULL || strstr (options , "nodev" ) != NULL )
155156 currentDisk -> type = FF_DISK_TYPE_EXTERNAL ;
@@ -183,8 +184,8 @@ void ffDetectDisksImpl(FFDiskResult* disks)
183184 return ;
184185 }
185186
186- FFstrbuf device ;
187- ffStrbufInit ( & device );
187+ FFlist devices ;
188+ ffListInit ( & devices , sizeof ( FFstrbuf ) );
188189
189190 char * line = NULL ;
190191 size_t len = 0 ;
@@ -201,8 +202,9 @@ void ffDetectDisksImpl(FFDiskResult* disks)
201202 char * currentPos = line ;
202203
203204 //detect device
204- ffStrbufClear (& device );
205- appendNextEntry (& device , & currentPos );
205+ FFstrbuf * device = ffListAdd (& devices );
206+ ffStrbufInit (device );
207+ appendNextEntry (device , & currentPos );
206208
207209 //detect mountpoint
208210 ffStrbufInit (& disk -> mountpoint );
@@ -214,10 +216,10 @@ void ffDetectDisksImpl(FFDiskResult* disks)
214216
215217 //detect name
216218 ffStrbufInit (& disk -> name );
217- detectName (disk , & device );
219+ detectName (disk , device );
218220
219221 //detect type
220- detectType (& disks -> disks , disk , currentPos );
222+ detectType (& devices , disk , currentPos );
221223
222224 //Detects stats
223225 detectStats (disk );
@@ -226,7 +228,9 @@ void ffDetectDisksImpl(FFDiskResult* disks)
226228 if (line != NULL )
227229 free (line );
228230
229- ffStrbufDestroy (& device );
231+ FF_LIST_FOR_EACH (FFstrbuf , device , devices )
232+ ffStrbufDestroy (device );
233+ ffListDestroy (& devices );
230234
231235 fclose (mountsFile );
232236}
0 commit comments