1#include <string.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 9struct mask_map { 10 int mask; 11 char *short_form; 12 char *long_form; 13}; 14 15static struct mask_map mask_maps[] = { 16 DECLARE_MASK_MAP(READ), 17 DECLARE_MASK_MAP(WRITE), 18 DECLARE_MASK_MAP(BARRIER), 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}; 32 33int find_mask_map(char *string) 34{ 35 unsigned int i; 36 37 for (i = 0; i < sizeof(mask_maps)/sizeof(mask_maps[0]); i++) 38 if (COMPARE_MASK_MAP(&mask_maps[i], string)) 39 return mask_maps[i].mask; 40 41 return -1; 42} 43 44int valid_act_opt(int x) 45{ 46 return (1 <= x) && (x < (1 << BLK_TC_SHIFT)); 47} 48