Home | History | Annotate | Download | only in blktrace
      1 #include <strings.h>
      2 #include "blktrace.h"
      3 
      4 #define DECLARE_MASK_MAP(mask)          { BLK_TC_##mask, #mask, "BLK_TC_"#mask }
      5 #define COMPARE_MASK_MAP(mmp, str)                                      \
      6         (!strcasecmp((mmp)->short_form, (str)) ||                      \
      7          !strcasecmp((mmp)->long_form, (str)))
      8 
      9 struct mask_map {
     10 	int mask;
     11 	char *short_form;
     12 	char *long_form;
     13 };
     14 
     15 static struct mask_map mask_maps[] = {
     16 	DECLARE_MASK_MAP(READ),
     17 	DECLARE_MASK_MAP(WRITE),
     18 	DECLARE_MASK_MAP(FLUSH),
     19 	DECLARE_MASK_MAP(SYNC),
     20 	DECLARE_MASK_MAP(QUEUE),
     21 	DECLARE_MASK_MAP(REQUEUE),
     22 	DECLARE_MASK_MAP(ISSUE),
     23 	DECLARE_MASK_MAP(COMPLETE),
     24 	DECLARE_MASK_MAP(FS),
     25 	DECLARE_MASK_MAP(PC),
     26 	DECLARE_MASK_MAP(NOTIFY),
     27 	DECLARE_MASK_MAP(AHEAD),
     28 	DECLARE_MASK_MAP(META),
     29 	DECLARE_MASK_MAP(DISCARD),
     30 	DECLARE_MASK_MAP(DRV_DATA),
     31 	DECLARE_MASK_MAP(FUA),
     32 };
     33 
     34 int find_mask_map(char *string)
     35 {
     36 	unsigned int i;
     37 
     38 	for (i = 0; i < sizeof(mask_maps)/sizeof(mask_maps[0]); i++)
     39 		if (COMPARE_MASK_MAP(&mask_maps[i], string))
     40 			return mask_maps[i].mask;
     41 
     42 	return -1;
     43 }
     44 
     45 int valid_act_opt(int x)
     46 {
     47 	return (1 <= x) && (x < (1 << BLK_TC_SHIFT));
     48 }
     49