devfs_rule.c (100793) | devfs_rule.c (104653) |
---|---|
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 100793 2002-07-28 03:52:44Z dd $ | 26 * $FreeBSD: head/sys/fs/devfs/devfs_rule.c 104653 2002-10-08 04:21:54Z dd $ |
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. --- 590 unchanged lines hidden (view full) --- 625 * Determine whether dk matches de on account of dr_pathptrn. 626 */ 627static int 628devfs_rule_matchpath(struct devfs_krule *dk, struct devfs_dirent *de) 629{ 630 struct devfs_rule *dr = &dk->dk_rule; 631 char *pname; 632 dev_t 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. --- 590 unchanged lines hidden (view full) --- 625 * Determine whether dk matches de on account of dr_pathptrn. 626 */ 627static int 628devfs_rule_matchpath(struct devfs_krule *dk, struct devfs_dirent *de) 629{ 630 struct devfs_rule *dr = &dk->dk_rule; 631 char *pname; 632 dev_t dev; |
633 int plen; | |
634 635 dev = devfs_rule_getdev(de); 636 if (dev != NULL) 637 pname = dev->si_name; 638 /* XXX: Support symlinks (check d_type == DT_LNK here). */ 639 else 640 return (0); 641 KASSERT(pname != NULL, ("devfs_rule_matchpath: NULL pname")); 642 | 633 634 dev = devfs_rule_getdev(de); 635 if (dev != NULL) 636 pname = dev->si_name; 637 /* XXX: Support symlinks (check d_type == DT_LNK here). */ 638 else 639 return (0); 640 KASSERT(pname != NULL, ("devfs_rule_matchpath: NULL pname")); 641 |
643 /* 644 * XXX: Interpret dr_pathptrn as a real pattern (support '*', 645 * '?', and perhaps brace expansion). For now, we only 646 * support one trailing asterisk. 647 */ 648 plen = strlen(dr->dr_pathptrn); 649 if (dr->dr_pathptrn[plen - 1] == '*') { 650 if (strlen(pname) >= plen - 1 && 651 strncmp(dr->dr_pathptrn, pname, plen - 1) == 0) 652 return (1); 653 } else 654 if (strcmp(dr->dr_pathptrn, pname) == 0) 655 return (1); 656 return (0); | 642 return (fnmatch(dr->dr_pathptrn, pname, 0) == 0); |
657} 658 659/* 660 * Run dk on de. 661 */ 662static void 663devfs_rule_run(struct devfs_krule *dk, struct devfs_dirent *de) 664{ --- 181 unchanged lines hidden --- | 643} 644 645/* 646 * Run dk on de. 647 */ 648static void 649devfs_rule_run(struct devfs_krule *dk, struct devfs_dirent *de) 650{ --- 181 unchanged lines hidden --- |