Deleted Added
full compact
devfs_rule.c (164033) devfs_rule.c (177458)
1/*-
2 * Copyright (c) 2002 Dima Dorfman.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2002 Dima Dorfman.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/fs/devfs/devfs_rule.c 164033 2006-11-06 13:42:10Z rwatson $
26 * $FreeBSD: head/sys/fs/devfs/devfs_rule.c 177458 2008-03-20 16:08:42Z kib $
27 */
28
29/*
30 * DEVFS ruleset implementation.
31 *
32 * A note on terminology: To "run" a rule on a dirent is to take the
33 * prescribed action; to "apply" a rule is to check whether it matches
34 * a dirent and run if if it does.

--- 487 unchanged lines hidden (view full) ---

522 * Determine whether dk matches de. Returns 1 if dk should be run on
523 * de; 0, otherwise.
524 */
525static int
526devfs_rule_match(struct devfs_krule *dk, struct devfs_dirent *de)
527{
528 struct devfs_rule *dr = &dk->dk_rule;
529 struct cdev *dev;
27 */
28
29/*
30 * DEVFS ruleset implementation.
31 *
32 * A note on terminology: To "run" a rule on a dirent is to take the
33 * prescribed action; to "apply" a rule is to check whether it matches
34 * a dirent and run if if it does.

--- 487 unchanged lines hidden (view full) ---

522 * Determine whether dk matches de. Returns 1 if dk should be run on
523 * de; 0, otherwise.
524 */
525static int
526devfs_rule_match(struct devfs_krule *dk, struct devfs_dirent *de)
527{
528 struct devfs_rule *dr = &dk->dk_rule;
529 struct cdev *dev;
530 struct cdevsw *dsw;
530
531 dev = devfs_rule_getdev(de);
532 /*
533 * At this point, if dev is NULL, we should assume that any
534 * criteria that depend on it don't match. We should *not*
535 * just ignore them (i.e., act like they weren't specified),
536 * since that makes a rule that only has criteria dependent on
537 * the struct cdev *match all symlinks and directories.
538 *
539 * Note also that the following tests are somewhat reversed:
540 * They're actually testing to see whether the condition does
541 * *not* match, since the default is to assume the rule should
542 * be run (such as if there are no conditions).
531
532 dev = devfs_rule_getdev(de);
533 /*
534 * At this point, if dev is NULL, we should assume that any
535 * criteria that depend on it don't match. We should *not*
536 * just ignore them (i.e., act like they weren't specified),
537 * since that makes a rule that only has criteria dependent on
538 * the struct cdev *match all symlinks and directories.
539 *
540 * Note also that the following tests are somewhat reversed:
541 * They're actually testing to see whether the condition does
542 * *not* match, since the default is to assume the rule should
543 * be run (such as if there are no conditions).
543 *
544 * XXX: lacks threadref on dev
545 */
544 */
546 if (dr->dr_icond & DRC_DSWFLAGS)
547 if (dev == NULL ||
548 (dev->si_devsw->d_flags & dr->dr_dswflags) == 0)
545 if (dr->dr_icond & DRC_DSWFLAGS) {
546 if (dev == NULL)
549 return (0);
547 return (0);
548 dsw = dev_refthread(dev);
549 if (dsw == NULL)
550 return (0);
551 if ((dsw->d_flags & dr->dr_dswflags) == 0) {
552 dev_relthread(dev);
553 return (0);
554 }
555 dev_relthread(dev);
556 }
550 if (dr->dr_icond & DRC_PATHPTRN)
551 if (!devfs_rule_matchpath(dk, de))
552 return (0);
553
554 return (1);
555}
556
557/*

--- 201 unchanged lines hidden ---
557 if (dr->dr_icond & DRC_PATHPTRN)
558 if (!devfs_rule_matchpath(dk, de))
559 return (0);
560
561 return (1);
562}
563
564/*

--- 201 unchanged lines hidden ---