1 #include <linux/list.h>
2 #include <linux/compiler.h>
13 #include "parse-events.h"
16 #include "pmu-events/pmu-events.h"
19 struct perf_pmu_format {
22 DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS);
23 struct list_head list;
26 #define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/"
28 int perf_pmu_parse(struct list_head *list, char *name);
29 extern FILE *perf_pmu_in;
31 static LIST_HEAD(pmus);
34 * Parse & process all the sysfs attributes located under
35 * the directory specified in 'dir' parameter.
37 int perf_pmu__format_parse(char *dir, struct list_head *head)
39 struct dirent *evt_ent;
43 format_dir = opendir(dir);
47 while (!ret && (evt_ent = readdir(format_dir))) {
49 char *name = evt_ent->d_name;
52 if (!strcmp(name, ".") || !strcmp(name, ".."))
55 snprintf(path, PATH_MAX, "%s/%s", dir, name);
58 file = fopen(path, "r");
63 ret = perf_pmu_parse(head, name);
72 * Reading/parsing the default pmu format definition, which should be
74 * /sys/bus/event_source/devices/<dev>/format as sysfs group attributes.
76 static int pmu_format(const char *name, struct list_head *format)
80 const char *sysfs = sysfs__mountpoint();
85 snprintf(path, PATH_MAX,
86 "%s" EVENT_SOURCE_DEVICE_PATH "%s/format", sysfs, name);
88 if (stat(path, &st) < 0)
89 return 0; /* no error if format does not exist */
91 if (perf_pmu__format_parse(path, format))
97 static int convert_scale(const char *scale, char **end, double *sval)
103 * save current locale
105 lc = setlocale(LC_NUMERIC, NULL);
108 * The lc string may be allocated in static storage,
109 * so get a dynamic copy to make it survive setlocale
119 * force to C locale to ensure kernel
120 * scale string is converted correctly.
121 * kernel uses default C locale.
123 setlocale(LC_NUMERIC, "C");
125 *sval = strtod(scale, end);
129 setlocale(LC_NUMERIC, lc);
134 static int perf_pmu__parse_scale(struct perf_pmu_alias *alias, char *dir, char *name)
142 snprintf(path, PATH_MAX, "%s/%s.scale", dir, name);
144 fd = open(path, O_RDONLY);
148 if (fstat(fd, &st) < 0)
151 sret = read(fd, scale, sizeof(scale)-1);
155 if (scale[sret - 1] == '\n')
156 scale[sret - 1] = '\0';
160 ret = convert_scale(scale, NULL, &alias->scale);
166 static int perf_pmu__parse_unit(struct perf_pmu_alias *alias, char *dir, char *name)
172 snprintf(path, PATH_MAX, "%s/%s.unit", dir, name);
174 fd = open(path, O_RDONLY);
178 sret = read(fd, alias->unit, UNIT_MAX_LEN);
184 if (alias->unit[sret - 1] == '\n')
185 alias->unit[sret - 1] = '\0';
187 alias->unit[sret] = '\0';
192 alias->unit[0] = '\0';
197 perf_pmu__parse_per_pkg(struct perf_pmu_alias *alias, char *dir, char *name)
202 snprintf(path, PATH_MAX, "%s/%s.per-pkg", dir, name);
204 fd = open(path, O_RDONLY);
210 alias->per_pkg = true;
214 static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias,
215 char *dir, char *name)
220 snprintf(path, PATH_MAX, "%s/%s.snapshot", dir, name);
222 fd = open(path, O_RDONLY);
226 alias->snapshot = true;
231 static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
232 char *desc, char *val,
233 char *long_desc, char *topic,
234 char *unit, char *perpkg)
236 struct perf_pmu_alias *alias;
240 alias = malloc(sizeof(*alias));
244 INIT_LIST_HEAD(&alias->terms);
246 alias->unit[0] = '\0';
247 alias->per_pkg = false;
248 alias->snapshot = false;
250 ret = parse_events_terms(&alias->terms, val);
252 pr_err("Cannot parse alias %s: %d\n", val, ret);
257 alias->name = strdup(name);
260 * load unit name and scale if available
262 perf_pmu__parse_unit(alias, dir, name);
263 perf_pmu__parse_scale(alias, dir, name);
264 perf_pmu__parse_per_pkg(alias, dir, name);
265 perf_pmu__parse_snapshot(alias, dir, name);
268 alias->desc = desc ? strdup(desc) : NULL;
269 alias->long_desc = long_desc ? strdup(long_desc) :
270 desc ? strdup(desc) : NULL;
271 alias->topic = topic ? strdup(topic) : NULL;
273 if (convert_scale(unit, &unit, &alias->scale) < 0)
275 snprintf(alias->unit, sizeof(alias->unit), "%s", unit);
277 alias->per_pkg = perpkg && sscanf(perpkg, "%d", &num) == 1 && num == 1;
278 list_add_tail(&alias->list, list);
283 static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FILE *file)
288 ret = fread(buf, 1, sizeof(buf), file);
294 return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL,
298 static inline bool pmu_alias_info_file(char *name)
303 if (len > 5 && !strcmp(name + len - 5, ".unit"))
305 if (len > 6 && !strcmp(name + len - 6, ".scale"))
307 if (len > 8 && !strcmp(name + len - 8, ".per-pkg"))
309 if (len > 9 && !strcmp(name + len - 9, ".snapshot"))
316 * Process all the sysfs attributes located under the directory
317 * specified in 'dir' parameter.
319 static int pmu_aliases_parse(char *dir, struct list_head *head)
321 struct dirent *evt_ent;
324 event_dir = opendir(dir);
328 while ((evt_ent = readdir(event_dir))) {
330 char *name = evt_ent->d_name;
333 if (!strcmp(name, ".") || !strcmp(name, ".."))
337 * skip info files parsed in perf_pmu__new_alias()
339 if (pmu_alias_info_file(name))
342 snprintf(path, PATH_MAX, "%s/%s", dir, name);
344 file = fopen(path, "r");
346 pr_debug("Cannot open %s\n", path);
350 if (perf_pmu__new_alias(head, dir, name, file) < 0)
351 pr_debug("Cannot set up %s\n", name);
360 * Reading the pmu event aliases definition, which should be located at:
361 * /sys/bus/event_source/devices/<dev>/events as sysfs group attributes.
363 static int pmu_aliases(const char *name, struct list_head *head)
367 const char *sysfs = sysfs__mountpoint();
372 snprintf(path, PATH_MAX,
373 "%s/bus/event_source/devices/%s/events", sysfs, name);
375 if (stat(path, &st) < 0)
376 return 0; /* no error if 'events' does not exist */
378 if (pmu_aliases_parse(path, head))
384 static int pmu_alias_terms(struct perf_pmu_alias *alias,
385 struct list_head *terms)
387 struct parse_events_term *term, *cloned;
391 list_for_each_entry(term, &alias->terms, list) {
392 ret = parse_events_term__clone(&cloned, term);
394 parse_events_terms__purge(&list);
397 list_add_tail(&cloned->list, &list);
399 list_splice(&list, terms);
404 * Reading/parsing the default pmu type value, which should be
406 * /sys/bus/event_source/devices/<dev>/type as sysfs attribute.
408 static int pmu_type(const char *name, __u32 *type)
414 const char *sysfs = sysfs__mountpoint();
419 snprintf(path, PATH_MAX,
420 "%s" EVENT_SOURCE_DEVICE_PATH "%s/type", sysfs, name);
422 if (stat(path, &st) < 0)
425 file = fopen(path, "r");
429 if (1 != fscanf(file, "%u", type))
436 /* Add all pmus in sysfs to pmu list: */
437 static void pmu_read_sysfs(void)
442 const char *sysfs = sysfs__mountpoint();
447 snprintf(path, PATH_MAX,
448 "%s" EVENT_SOURCE_DEVICE_PATH, sysfs);
454 while ((dent = readdir(dir))) {
455 if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
457 /* add to static LIST_HEAD(pmus): */
458 perf_pmu__find(dent->d_name);
464 static struct cpu_map *pmu_cpumask(const char *name)
469 struct cpu_map *cpus;
470 const char *sysfs = sysfs__mountpoint();
471 const char *templates[] = {
472 "%s/bus/event_source/devices/%s/cpumask",
473 "%s/bus/event_source/devices/%s/cpus",
476 const char **template;
481 for (template = templates; *template; template++) {
482 snprintf(path, PATH_MAX, *template, sysfs, name);
483 if (stat(path, &st) == 0)
490 file = fopen(path, "r");
494 cpus = cpu_map__read(file);
500 * Return the CPU id as a raw string.
502 * Each architecture should provide a more precise id string that
503 * can be use to match the architecture's "mapfile".
505 char * __weak get_cpuid_str(void)
511 * From the pmu_events_map, find the table of PMU events that corresponds
512 * to the current running CPU. Then, add all PMU events from that table
515 static void pmu_add_cpu_aliases(struct list_head *head, const char *name)
518 struct pmu_events_map *map;
519 struct pmu_event *pe;
523 cpuid = getenv("PERF_CPUID");
525 cpuid = strdup(cpuid);
527 cpuid = get_cpuid_str();
532 pr_debug("Using CPUID %s\n", cpuid);
538 map = &pmu_events_map[i++];
542 if (!strcmp(map->cpuid, cpuid))
547 * Found a matching PMU events table. Create aliases
553 pe = &map->table[i++];
557 pname = pe->pmu ? pe->pmu : "cpu";
558 if (strncmp(pname, name, strlen(pname)))
561 /* need type casts to override 'const' */
562 __perf_pmu__new_alias(head, NULL, (char *)pe->name,
563 (char *)pe->desc, (char *)pe->event,
564 (char *)pe->long_desc, (char *)pe->topic,
565 (char *)pe->unit, (char *)pe->perpkg);
572 struct perf_event_attr * __weak
573 perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
578 static struct perf_pmu *pmu_lookup(const char *name)
580 struct perf_pmu *pmu;
586 * The pmu data we store & need consists of the pmu
587 * type value and format definitions. Load both right
590 if (pmu_format(name, &format))
593 if (pmu_aliases(name, &aliases))
596 pmu_add_cpu_aliases(&aliases, name);
598 if (pmu_type(name, &type))
601 pmu = zalloc(sizeof(*pmu));
605 pmu->cpus = pmu_cpumask(name);
607 INIT_LIST_HEAD(&pmu->format);
608 INIT_LIST_HEAD(&pmu->aliases);
609 list_splice(&format, &pmu->format);
610 list_splice(&aliases, &pmu->aliases);
611 pmu->name = strdup(name);
613 list_add_tail(&pmu->list, &pmus);
615 pmu->default_config = perf_pmu__get_default_config(pmu);
620 static struct perf_pmu *pmu_find(const char *name)
622 struct perf_pmu *pmu;
624 list_for_each_entry(pmu, &pmus, list)
625 if (!strcmp(pmu->name, name))
631 struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu)
634 * pmu iterator: If pmu is NULL, we start at the begin,
635 * otherwise return the next pmu. Returns NULL on end.
639 pmu = list_prepare_entry(pmu, &pmus, list);
641 list_for_each_entry_continue(pmu, &pmus, list)
646 struct perf_pmu *perf_pmu__find(const char *name)
648 struct perf_pmu *pmu;
651 * Once PMU is loaded it stays in the list,
652 * so we keep us from multiple reading/parsing
653 * the pmu format definitions.
655 pmu = pmu_find(name);
659 return pmu_lookup(name);
662 static struct perf_pmu_format *
663 pmu_find_format(struct list_head *formats, const char *name)
665 struct perf_pmu_format *format;
667 list_for_each_entry(format, formats, list)
668 if (!strcmp(format->name, name))
674 __u64 perf_pmu__format_bits(struct list_head *formats, const char *name)
676 struct perf_pmu_format *format = pmu_find_format(formats, name);
683 for_each_set_bit(fbit, format->bits, PERF_PMU_FORMAT_BITS)
684 bits |= 1ULL << fbit;
690 * Sets value based on the format definition (format parameter)
691 * and unformated value (value parameter).
693 static void pmu_format_value(unsigned long *format, __u64 value, __u64 *v,
696 unsigned long fbit, vbit;
698 for (fbit = 0, vbit = 0; fbit < PERF_PMU_FORMAT_BITS; fbit++) {
700 if (!test_bit(fbit, format))
703 if (value & (1llu << vbit++))
704 *v |= (1llu << fbit);
706 *v &= ~(1llu << fbit);
710 static __u64 pmu_format_max_value(const unsigned long *format)
715 for_each_set_bit(fbit, format, PERF_PMU_FORMAT_BITS)
722 * Term is a string term, and might be a param-term. Try to look up it's value
723 * in the remaining terms.
724 * - We have a term like "base-or-format-term=param-term",
725 * - We need to find the value supplied for "param-term" (with param-term named
726 * in a config string) later on in the term list.
728 static int pmu_resolve_param_term(struct parse_events_term *term,
729 struct list_head *head_terms,
732 struct parse_events_term *t;
734 list_for_each_entry(t, head_terms, list) {
735 if (t->type_val == PARSE_EVENTS__TERM_TYPE_NUM) {
736 if (!strcmp(t->config, term->config)) {
745 printf("Required parameter '%s' not specified\n", term->config);
750 static char *pmu_formats_string(struct list_head *formats)
752 struct perf_pmu_format *format;
754 struct strbuf buf = STRBUF_INIT;
760 /* sysfs exported terms */
761 list_for_each_entry(format, formats, list)
762 if (strbuf_addf(&buf, i++ ? ",%s" : "%s", format->name) < 0)
765 str = strbuf_detach(&buf, NULL);
767 strbuf_release(&buf);
773 * Setup one of config[12] attr members based on the
774 * user input data - term parameter.
776 static int pmu_config_term(struct list_head *formats,
777 struct perf_event_attr *attr,
778 struct parse_events_term *term,
779 struct list_head *head_terms,
780 bool zero, struct parse_events_error *err)
782 struct perf_pmu_format *format;
787 * If this is a parameter we've already used for parameterized-eval,
788 * skip it in normal eval.
794 * Hardcoded terms should be already in, so nothing
795 * to be done for them.
797 if (parse_events__is_hardcoded_term(term))
800 format = pmu_find_format(formats, term->config);
803 printf("Invalid event/parameter '%s'\n", term->config);
805 char *pmu_term = pmu_formats_string(formats);
807 err->idx = term->err_term;
808 err->str = strdup("unknown term");
809 err->help = parse_events_formats_error_string(pmu_term);
815 switch (format->value) {
816 case PERF_PMU_FORMAT_VALUE_CONFIG:
819 case PERF_PMU_FORMAT_VALUE_CONFIG1:
822 case PERF_PMU_FORMAT_VALUE_CONFIG2:
830 * Either directly use a numeric term, or try to translate string terms
831 * using event parameters.
833 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM)
835 else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) {
836 if (strcmp(term->val.str, "?")) {
838 pr_info("Invalid sysfs entry %s=%s\n",
839 term->config, term->val.str);
842 err->idx = term->err_val;
843 err->str = strdup("expected numeric value");
848 if (pmu_resolve_param_term(term, head_terms, &val))
853 max_val = pmu_format_max_value(format->bits);
856 err->idx = term->err_val;
857 if (asprintf(&err->str,
858 "value too big for format, maximum is %llu",
859 (unsigned long long)max_val) < 0)
860 err->str = strdup("value too big for format");
864 * Assume we don't care if !err, in which case the value will be
865 * silently truncated.
869 pmu_format_value(format->bits, val, vp, zero);
873 int perf_pmu__config_terms(struct list_head *formats,
874 struct perf_event_attr *attr,
875 struct list_head *head_terms,
876 bool zero, struct parse_events_error *err)
878 struct parse_events_term *term;
880 list_for_each_entry(term, head_terms, list) {
881 if (pmu_config_term(formats, attr, term, head_terms,
890 * Configures event's 'attr' parameter based on the:
891 * 1) users input - specified in terms parameter
892 * 2) pmu format definitions - specified by pmu parameter
894 int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
895 struct list_head *head_terms,
896 struct parse_events_error *err)
898 bool zero = !!pmu->default_config;
900 attr->type = pmu->type;
901 return perf_pmu__config_terms(&pmu->format, attr, head_terms,
905 static struct perf_pmu_alias *pmu_find_alias(struct perf_pmu *pmu,
906 struct parse_events_term *term)
908 struct perf_pmu_alias *alias;
911 if (parse_events__is_hardcoded_term(term))
914 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM) {
915 if (term->val.num != 1)
917 if (pmu_find_format(&pmu->format, term->config))
920 } else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) {
921 if (strcasecmp(term->config, "event"))
923 name = term->val.str;
928 list_for_each_entry(alias, &pmu->aliases, list) {
929 if (!strcasecmp(alias->name, name))
936 static int check_info_data(struct perf_pmu_alias *alias,
937 struct perf_pmu_info *info)
940 * Only one term in event definition can
941 * define unit, scale and snapshot, fail
942 * if there's more than one.
944 if ((info->unit && alias->unit) ||
945 (info->scale && alias->scale) ||
946 (info->snapshot && alias->snapshot))
950 info->unit = alias->unit;
953 info->scale = alias->scale;
956 info->snapshot = alias->snapshot;
962 * Find alias in the terms list and replace it with the terms
963 * defined for the alias
965 int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
966 struct perf_pmu_info *info)
968 struct parse_events_term *term, *h;
969 struct perf_pmu_alias *alias;
972 info->per_pkg = false;
975 * Mark unit and scale as not set
976 * (different from default values, see below)
980 info->snapshot = false;
982 list_for_each_entry_safe(term, h, head_terms, list) {
983 alias = pmu_find_alias(pmu, term);
986 ret = pmu_alias_terms(alias, &term->list);
990 ret = check_info_data(alias, info);
995 info->per_pkg = true;
997 list_del(&term->list);
1002 * if no unit or scale foundin aliases, then
1003 * set defaults as for evsel
1004 * unit cannot left to NULL
1006 if (info->unit == NULL)
1009 if (info->scale == 0.0)
1015 int perf_pmu__new_format(struct list_head *list, char *name,
1016 int config, unsigned long *bits)
1018 struct perf_pmu_format *format;
1020 format = zalloc(sizeof(*format));
1024 format->name = strdup(name);
1025 format->value = config;
1026 memcpy(format->bits, bits, sizeof(format->bits));
1028 list_add_tail(&format->list, list);
1032 void perf_pmu__set_format(unsigned long *bits, long from, long to)
1039 memset(bits, 0, BITS_TO_BYTES(PERF_PMU_FORMAT_BITS));
1040 for (b = from; b <= to; b++)
1044 static int sub_non_neg(int a, int b)
1051 static char *format_alias(char *buf, int len, struct perf_pmu *pmu,
1052 struct perf_pmu_alias *alias)
1054 struct parse_events_term *term;
1055 int used = snprintf(buf, len, "%s/%s", pmu->name, alias->name);
1057 list_for_each_entry(term, &alias->terms, list) {
1058 if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR)
1059 used += snprintf(buf + used, sub_non_neg(len, used),
1060 ",%s=%s", term->config,
1064 if (sub_non_neg(len, used) > 0) {
1068 if (sub_non_neg(len, used) > 0) {
1072 buf[len - 1] = '\0';
1077 static char *format_alias_or(char *buf, int len, struct perf_pmu *pmu,
1078 struct perf_pmu_alias *alias)
1080 snprintf(buf, len, "%s OR %s/%s/", alias->name, pmu->name, alias->name);
1090 static int cmp_sevent(const void *a, const void *b)
1092 const struct sevent *as = a;
1093 const struct sevent *bs = b;
1095 /* Put extra events last */
1096 if (!!as->desc != !!bs->desc)
1097 return !!as->desc - !!bs->desc;
1098 if (as->topic && bs->topic) {
1099 int n = strcmp(as->topic, bs->topic);
1104 return strcmp(as->name, bs->name);
1107 static void wordwrap(char *s, int start, int max, int corr)
1113 int wlen = strcspn(s, " \t");
1115 if (column + wlen >= max && column > start) {
1116 printf("\n%*s", start, "");
1117 column = start + corr;
1119 n = printf("%s%.*s", column > start ? " " : "", wlen, s);
1129 void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
1132 struct perf_pmu *pmu;
1133 struct perf_pmu_alias *alias;
1137 struct sevent *aliases;
1139 int columns = pager_get_columns();
1144 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
1145 list_for_each_entry(alias, &pmu->aliases, list)
1147 if (pmu->selectable)
1150 aliases = zalloc(sizeof(struct sevent) * len);
1155 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
1156 list_for_each_entry(alias, &pmu->aliases, list) {
1157 char *name = alias->desc ? alias->name :
1158 format_alias(buf, sizeof(buf), pmu, alias);
1159 bool is_cpu = !strcmp(pmu->name, "cpu");
1161 if (event_glob != NULL &&
1162 !(strglobmatch_nocase(name, event_glob) ||
1163 (!is_cpu && strglobmatch_nocase(alias->name,
1166 strglobmatch_nocase(alias->topic, event_glob))))
1169 if (is_cpu && !name_only && !alias->desc)
1170 name = format_alias_or(buf, sizeof(buf), pmu, alias);
1172 aliases[j].name = name;
1173 if (is_cpu && !name_only && !alias->desc)
1174 aliases[j].name = format_alias_or(buf,
1177 aliases[j].name = strdup(aliases[j].name);
1178 if (!aliases[j].name)
1181 aliases[j].desc = long_desc ? alias->long_desc :
1183 aliases[j].topic = alias->topic;
1186 if (pmu->selectable &&
1187 (event_glob == NULL || strglobmatch(pmu->name, event_glob))) {
1189 if (asprintf(&s, "%s//", pmu->name) < 0)
1191 aliases[j].name = s;
1196 qsort(aliases, len, sizeof(struct sevent), cmp_sevent);
1197 for (j = 0; j < len; j++) {
1199 printf("%s ", aliases[j].name);
1202 if (aliases[j].desc && !quiet_flag) {
1205 if (aliases[j].topic && (!topic ||
1206 strcmp(topic, aliases[j].topic))) {
1207 printf("%s%s:\n", topic ? "\n" : "",
1209 topic = aliases[j].topic;
1211 printf(" %-50s\n", aliases[j].name);
1212 printf("%*s", 8, "[");
1213 wordwrap(aliases[j].desc, 8, columns, 0);
1216 printf(" %-50s [Kernel PMU event]\n", aliases[j].name);
1219 if (printed && pager_in_use())
1222 for (j = 0; j < len; j++)
1223 zfree(&aliases[j].name);
1228 printf("FATAL: not enough memory to print PMU events\n");
1233 bool pmu_have_event(const char *pname, const char *name)
1235 struct perf_pmu *pmu;
1236 struct perf_pmu_alias *alias;
1239 while ((pmu = perf_pmu__scan(pmu)) != NULL) {
1240 if (strcmp(pname, pmu->name))
1242 list_for_each_entry(alias, &pmu->aliases, list)
1243 if (!strcmp(alias->name, name))
1249 static FILE *perf_pmu__open_file(struct perf_pmu *pmu, const char *name)
1252 char path[PATH_MAX];
1255 sysfs = sysfs__mountpoint();
1259 snprintf(path, PATH_MAX,
1260 "%s" EVENT_SOURCE_DEVICE_PATH "%s/%s", sysfs, pmu->name, name);
1262 if (stat(path, &st) < 0)
1265 return fopen(path, "r");
1268 int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
1275 va_start(args, fmt);
1276 file = perf_pmu__open_file(pmu, name);
1278 ret = vfscanf(file, fmt, args);