Lines Matching +full:spec +full:-
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
9 * DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA
55 const char *modestr; /* print-worthy ",-?" mode string */
97 -1) { in main()
127 argc -= optind; in main()
134 argc--; in main()
144 switch (ftsent->fts_info) { in main()
145 case FTS_DP: /* skip post-order */ in main()
147 case FTS_D: /* do pre-order */ in main()
160 ftsent->fts_path); in main()
164 ftsent->fts_path); in main()
171 err(1, "traversing %s", ftsent->fts_path); in main()
174 ftsent->fts_info, ftsent->fts_path); in main()
188 fprintf(stderr, "usage: setfmac [-Rhq] label file ...\n"); in usage()
190 fprintf(stderr, "usage: setfsmac [-ehqvx] [-f specfile [...]] [-s specfile [...]] file ...\n"); in usage()
200 for (s = *line; (unsigned)(s - *line) < *linesize; s++) { in chomp_line()
209 memmove(*line, s, *linesize - (s - *line)); in chomp_line()
210 *linesize -= s - *line; in chomp_line()
211 for (s = &(*line)[*linesize - 1]; s >= *line; s--) { in chomp_line()
215 if (s != &(*line)[*linesize - 1]) { in chomp_line()
216 *linesize = s - *line + 1; in chomp_line()
232 struct label_spec *spec; in add_specs() local
238 spec = malloc(sizeof(*spec)); in add_specs()
239 if (spec == NULL) in add_specs()
246 if (linesize > 0) /* only allocate space for non-comments */ in add_specs()
254 spec->entries = calloc(nlines, sizeof(*spec->entries)); in add_specs()
255 if (spec->entries == NULL) in add_specs()
257 spec->nentries = nlines; in add_specs()
272 add_spec_line(file, is_sebsd, &spec->entries[--nlines], line); in add_specs()
279 (long)spec->nentries); in add_specs()
280 STAILQ_INSERT_TAIL(&specs->head, spec, link); in add_specs()
286 struct label_spec *spec; in add_setfmac_specs() local
288 spec = malloc(sizeof(*spec)); in add_setfmac_specs()
289 if (spec == NULL) in add_setfmac_specs()
291 spec->nentries = 1; in add_setfmac_specs()
292 spec->entries = calloc(spec->nentries, sizeof(*spec->entries)); in add_setfmac_specs()
293 if (spec->entries == NULL) in add_setfmac_specs()
296 spec->entries->mactext = label; in add_setfmac_specs()
297 spec->entries->flags |= F_ALWAYSMATCH; in add_setfmac_specs()
298 STAILQ_INSERT_TAIL(&specs->head, spec, link); in add_setfmac_specs()
323 if (asprintf(®exstr, "^%s$", regexstr) == -1) in add_spec_line()
325 entry->regexstr = regexstr; in add_spec_line()
326 error = regcomp(&entry->regex, regexstr, REG_EXTENDED | REG_NOSUB); in add_spec_line()
328 size = regerror(error, &entry->regex, NULL, 0); in add_spec_line()
332 (void)regerror(error, &entry->regex, regerrorstr, size); in add_spec_line()
333 errx(1, "%s: %s: %s", file, entry->regexstr, regerrorstr); in add_spec_line()
336 entry->mactext = strdup(macstr); in add_spec_line()
337 if (entry->mactext == NULL) in add_spec_line()
340 if (asprintf(&entry->mactext, "sebsd/%s", macstr) == -1) in add_spec_line()
343 entry->flags |= F_DONTLABEL; in add_spec_line()
346 if (strlen(modestr) != 2 || modestr[0] != '-') in add_spec_line()
350 entry->mode = S_IFBLK; in add_spec_line()
351 entry->modestr = ",-b"; in add_spec_line()
354 entry->mode = S_IFCHR; in add_spec_line()
355 entry->modestr = ",-c"; in add_spec_line()
358 entry->mode = S_IFDIR; in add_spec_line()
359 entry->modestr = ",-d"; in add_spec_line()
362 entry->mode = S_IFIFO; in add_spec_line()
363 entry->modestr = ",-p"; in add_spec_line()
366 entry->mode = S_IFLNK; in add_spec_line()
367 entry->modestr = ",-l"; in add_spec_line()
370 entry->mode = S_IFSOCK; in add_spec_line()
371 entry->modestr = ",-s"; in add_spec_line()
373 case '-': in add_spec_line()
374 entry->mode = S_IFREG; in add_spec_line()
375 entry->modestr = ",--"; in add_spec_line()
381 entry->modestr = ""; in add_spec_line()
389 return (STAILQ_EMPTY(&specs->head)); in specs_empty()
409 STAILQ_FOREACH(ls, &specs->head, link) { in apply_specs()
410 for (ls->match = NULL, ent = ls->entries; in apply_specs()
411 ent < &ls->entries[ls->nentries]; ent++) { in apply_specs()
412 if (ent->flags & F_ALWAYSMATCH) in apply_specs()
414 if (ent->mode != 0 && in apply_specs()
415 (ftsent->fts_statp->st_mode & S_IFMT) != ent->mode) in apply_specs()
418 pmatch.rm_eo = ftsent->fts_pathlen; in apply_specs()
419 error = regexec(&ent->regex, ftsent->fts_path, 1, in apply_specs()
427 size = regerror(error, &ent->regex, NULL, 0); in apply_specs()
431 (void)regerror(error, &ent->regex, regerrorstr, in apply_specs()
433 errx(1, "%s: %s", ent->regexstr, regerrorstr); in apply_specs()
436 ls->match = ent; in apply_specs()
440 ftsent->fts_path); in apply_specs()
444 ent->regexstr, ent->modestr, ent->mactext); in apply_specs()
454 STAILQ_FOREACH(ls, &specs->head, link) { in apply_specs()
456 if (ls->match && (ls->match->flags & F_DONTLABEL) == 0) in apply_specs()
458 size += strlen(ls->match->mactext) + 1; in apply_specs()
466 STAILQ_FOREACH(ls, &specs->head, link) { in apply_specs()
468 if (ls->match && (ls->match->flags & F_DONTLABEL) == 0) { in apply_specs()
471 strcat(macstr, ls->match->mactext); in apply_specs()
476 if ((hflag == FTS_PHYSICAL ? mac_set_link(ftsent->fts_accpath, mac) : in apply_specs()
477 mac_set_file(ftsent->fts_accpath, mac)) != 0) { in apply_specs()
483 err(1, "mac_set_link(%s, %s)", ftsent->fts_path, macstr); in apply_specs()
498 STAILQ_INIT(&specs->head); in new_specs()