From f265a76cb4d51974fc185d43053f691c0b2b0d07 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 20 Feb 1997 02:28:06 +0000 Subject: (dev_set_flags): Correctly check for unenforcable runs. --- libstore/device.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'libstore') diff --git a/libstore/device.c b/libstore/device.c index 4c50d777..7ae66ed0 100644 --- a/libstore/device.c +++ b/libstore/device.c @@ -1,6 +1,6 @@ /* Mach device store backend - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. Written by Miles Bader @@ -135,19 +135,28 @@ static error_t dev_set_flags (struct store *store, int flags) { if ((flags & ~(STORE_INACTIVE | STORE_ENFORCED)) != 0) + /* Trying to set flags we don't support. */ return EINVAL; + if (! ((store->flags | flags) & STORE_INACTIVE)) - if (store->num_runs >= 0 || store->runs[0].start != 0) + /* Currently active and staying that way, so we must be trying to set the + STORE_ENFORCED flag. */ + if (store->num_runs > 0 || store->runs[0].start != 0) + /* Can't enforce non-contiguous ranges, or one not starting at 0. */ return EINVAL; - else if (flags & STORE_ENFORCED) + else + /* See if the the current (one) range is that the kernel is enforcing. */ { error_t err = enforced (store); if (err) return err; } + if (flags & STORE_INACTIVE) dclose (store); + store->flags |= flags; /* When inactive, anything goes. */ + return 0; } -- cgit v1.2.3