devfs_rule.c (109090) | devfs_rule.c (109623) |
---|---|
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 109090 2003-01-11 02:36:20Z dd $ | 26 * $FreeBSD: head/sys/fs/devfs/devfs_rule.c 109623 2003-01-21 08:56:16Z alfred $ |
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. --- 183 unchanged lines hidden (view full) --- 218 * code (not that this implementation doesn't do 219 * that). 220 */ 221 if (dr->dr_iacts & DRA_INCSET && 222 devfs_ruleset_bynum(dr->dr_incset) == NULL) { 223 error = ESRCH; 224 goto out; 225 } | 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. --- 183 unchanged lines hidden (view full) --- 218 * code (not that this implementation doesn't do 219 * that). 220 */ 221 if (dr->dr_iacts & DRA_INCSET && 222 devfs_ruleset_bynum(dr->dr_incset) == NULL) { 223 error = ESRCH; 224 goto out; 225 } |
226 dk = malloc(sizeof(*dk), M_TEMP, M_WAITOK | M_ZERO); | 226 dk = malloc(sizeof(*dk), M_TEMP, M_ZERO); |
227 memcpy(&dk->dk_rule, dr, sizeof(*dr)); 228 lockmgr(&dm->dm_lock, LK_UPGRADE, 0, td); 229 devfs_rule_applydm(dk, dm); 230 lockmgr(&dm->dm_lock, LK_DOWNGRADE, 0, td); 231 free(dk, M_TEMP); 232 error = 0; 233 break; 234 case DEVFSIO_RAPPLYID: --- 317 unchanged lines hidden (view full) --- 552 return (EIO); 553 dkrn = rid2rn(dr->dr_id); 554 if (dkrn == 0) { 555 error = devfs_rule_autonumber(ds, &dkrn); 556 if (error != 0) 557 return (error); 558 } 559 | 227 memcpy(&dk->dk_rule, dr, sizeof(*dr)); 228 lockmgr(&dm->dm_lock, LK_UPGRADE, 0, td); 229 devfs_rule_applydm(dk, dm); 230 lockmgr(&dm->dm_lock, LK_DOWNGRADE, 0, td); 231 free(dk, M_TEMP); 232 error = 0; 233 break; 234 case DEVFSIO_RAPPLYID: --- 317 unchanged lines hidden (view full) --- 552 return (EIO); 553 dkrn = rid2rn(dr->dr_id); 554 if (dkrn == 0) { 555 error = devfs_rule_autonumber(ds, &dkrn); 556 if (error != 0) 557 return (error); 558 } 559 |
560 dk = malloc(sizeof(*dk), M_DEVFS, M_WAITOK); | 560 dk = malloc(sizeof(*dk), M_DEVFS, 0); |
561 dk->dk_ruleset = ds; 562 if (dsi != NULL) 563 ++dsi->ds_refcount; 564 /* XXX: Inspect dr? */ 565 memcpy(&dk->dk_rule, dr, sizeof(*dr)); 566 dk->dk_rule.dr_id = mkrid(rid2rsn(dk->dk_rule.dr_id), dkrn); 567 568 k1 = SLIST_FIRST(&ds->ds_rules); --- 176 unchanged lines hidden (view full) --- 745devfs_ruleset_create(devfs_rsnum rsnum) 746{ 747 struct devfs_ruleset *s1, *s2; 748 struct devfs_ruleset *ds; 749 750 KASSERT(devfs_ruleset_bynum(rsnum) == NULL, 751 ("creating already existent ruleset %d", rsnum)); 752 | 561 dk->dk_ruleset = ds; 562 if (dsi != NULL) 563 ++dsi->ds_refcount; 564 /* XXX: Inspect dr? */ 565 memcpy(&dk->dk_rule, dr, sizeof(*dr)); 566 dk->dk_rule.dr_id = mkrid(rid2rsn(dk->dk_rule.dr_id), dkrn); 567 568 k1 = SLIST_FIRST(&ds->ds_rules); --- 176 unchanged lines hidden (view full) --- 745devfs_ruleset_create(devfs_rsnum rsnum) 746{ 747 struct devfs_ruleset *s1, *s2; 748 struct devfs_ruleset *ds; 749 750 KASSERT(devfs_ruleset_bynum(rsnum) == NULL, 751 ("creating already existent ruleset %d", rsnum)); 752 |
753 ds = malloc(sizeof(*ds), M_DEVFS, M_WAITOK | M_ZERO); | 753 ds = malloc(sizeof(*ds), M_DEVFS, M_ZERO); |
754 ds->ds_number = rsnum; 755 ds->ds_refcount = ds->ds_flags = 0; 756 SLIST_INIT(&ds->ds_rules); 757 758 s1 = SLIST_FIRST(&devfs_rulesets); 759 if (s1 == NULL || s1->ds_number > rsnum) 760 SLIST_INSERT_HEAD(&devfs_rulesets, ds, ds_list); 761 else { --- 71 unchanged lines hidden --- | 754 ds->ds_number = rsnum; 755 ds->ds_refcount = ds->ds_flags = 0; 756 SLIST_INIT(&ds->ds_rules); 757 758 s1 = SLIST_FIRST(&devfs_rulesets); 759 if (s1 == NULL || s1->ds_number > rsnum) 760 SLIST_INSERT_HEAD(&devfs_rulesets, ds, ds_list); 761 else { --- 71 unchanged lines hidden --- |