@@ -211,13 +211,57 @@ static bool usb_bus_dir_selector(const char* d_name, const void** next_sel, size
211
211
return rc ;
212
212
}
213
213
214
+ static bool nvme_namespace_dir_selector (const char * d_name , const void * * next_sel , size_t * n_next_sel )
215
+ {
216
+ unsigned int dummy ;
217
+ bool rc = (2 == sscanf (d_name , "nvme%un%u" , & dummy , & dummy ));
218
+
219
+ if (rc && next_sel && n_next_sel )
220
+ {
221
+ * next_sel = NULL ;
222
+ * n_next_sel = 0 ;
223
+ }
224
+
225
+ return rc ;
226
+ }
227
+
228
+ static bool nvme_dev_dir_selector (const char * d_name , const void * * next_sel , size_t * n_next_sel )
229
+ {
230
+ static const dir_selector_fn next_selectors [] = { nvme_namespace_dir_selector };
231
+ unsigned int dummy ;
232
+ bool rc = (1 == sscanf (d_name , "nvme%u" , & dummy ));
233
+
234
+ if (rc && next_sel && n_next_sel )
235
+ {
236
+ * next_sel = next_selectors ;
237
+ * n_next_sel = ARRAY_SIZE (next_selectors );
238
+ }
239
+
240
+ return rc ;
241
+ }
242
+
243
+ static bool nvme_bus_dir_selector (const char * d_name , const void * * next_sel , size_t * n_next_sel )
244
+ {
245
+ static const dir_selector_fn next_selectors [] = { nvme_dev_dir_selector };
246
+ bool rc = (0 == strcmp (d_name , "nvme" ));
247
+
248
+ if (rc && next_sel && n_next_sel )
249
+ {
250
+ * next_sel = next_selectors ;
251
+ * n_next_sel = ARRAY_SIZE (next_selectors );
252
+ }
253
+
254
+ return rc ;
255
+ }
256
+
214
257
static bool pci_dev_dir_selector (const char * d_name , const void * * next_sel , size_t * n_next_sel )
215
258
{
216
259
static const dir_selector_fn next_selectors [] = {
217
260
pci_dev_dir_selector
218
261
, ata_dev_dir_selector
219
262
, scsi_host_dir_selector
220
263
, usb_bus_dir_selector
264
+ , nvme_bus_dir_selector
221
265
};
222
266
unsigned int dummy ;
223
267
bool rc = (4 == sscanf (d_name , "%4x:%2x:%2x.%x" , & dummy , & dummy , & dummy , & dummy ));
0 commit comments