Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.
All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.
All imported code from other projects is compatible with this license.
All GPL licensed code from other projects had previously been removed.
Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-02 17:38:16 -05:00
|
|
|
/*
|
2021-12-17 18:05:46 -05:00
|
|
|
* Copyright (c) 2011-2016, 2021 Jonas 'Sortie' Termansen.
|
Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.
All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.
All imported code from other projects is compatible with this license.
All GPL licensed code from other projects had previously been removed.
Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-02 17:38:16 -05:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* dtable.cpp
|
|
|
|
* Table of file descriptors.
|
|
|
|
*/
|
2012-08-07 18:19:44 -04:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
2013-01-15 19:45:51 -05:00
|
|
|
#include <limits.h>
|
2012-08-07 18:19:44 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
2013-10-26 20:42:10 -04:00
|
|
|
#include <sortix/fcntl.h>
|
|
|
|
|
|
|
|
#include <sortix/kernel/descriptor.h>
|
|
|
|
#include <sortix/kernel/dtable.h>
|
|
|
|
#include <sortix/kernel/kernel.h>
|
|
|
|
#include <sortix/kernel/kthread.h>
|
|
|
|
#include <sortix/kernel/process.h>
|
|
|
|
#include <sortix/kernel/refcount.h>
|
|
|
|
|
2012-08-07 18:19:44 -04:00
|
|
|
namespace Sortix {
|
|
|
|
|
2021-12-17 18:05:46 -05:00
|
|
|
struct DescriptorEntry
|
|
|
|
{
|
|
|
|
Ref<Descriptor> desc;
|
|
|
|
int flags;
|
|
|
|
};
|
|
|
|
|
2012-08-07 18:19:44 -04:00
|
|
|
DescriptorTable::DescriptorTable()
|
|
|
|
{
|
|
|
|
dtablelock = KTHREAD_MUTEX_INITIALIZER;
|
|
|
|
entries = NULL;
|
2021-12-17 18:05:46 -05:00
|
|
|
entries_used = 0;
|
|
|
|
entries_length = 0;
|
|
|
|
reserved_count = 0;
|
2014-08-20 18:02:37 -04:00
|
|
|
first_not_taken = 0;
|
2012-08-07 18:19:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
DescriptorTable::~DescriptorTable()
|
|
|
|
{
|
2021-12-17 18:05:46 -05:00
|
|
|
for ( int i = 0; i < entries_length; i++ )
|
|
|
|
if ( entries[i].desc )
|
|
|
|
entries[i].desc.Reset();
|
|
|
|
delete[] entries;
|
2012-08-07 18:19:44 -04:00
|
|
|
}
|
|
|
|
|
2021-12-17 18:05:46 -05:00
|
|
|
bool DescriptorTable::IsGoodEntry(int i) // dtablelock locked
|
2012-08-07 18:19:44 -04:00
|
|
|
{
|
2021-12-17 18:05:46 -05:00
|
|
|
return 0 <= i && i < entries_length && entries[i].desc;
|
2012-08-07 18:19:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Ref<DescriptorTable> DescriptorTable::Fork()
|
|
|
|
{
|
|
|
|
ScopedLock lock(&dtablelock);
|
|
|
|
Ref<DescriptorTable> ret(new DescriptorTable);
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( !ret )
|
|
|
|
return Ref<DescriptorTable>(NULL);
|
2021-12-17 18:05:46 -05:00
|
|
|
ret->entries = new DescriptorEntry[entries_length];
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( !ret->entries )
|
|
|
|
return Ref<DescriptorTable>(NULL);
|
2021-12-17 18:05:46 -05:00
|
|
|
// Copy all the file descriptors except ones closed on fork.
|
|
|
|
ret->entries_length = entries_length;
|
|
|
|
for ( int i = 0; i < entries_length; i++ )
|
2012-08-07 18:19:44 -04:00
|
|
|
{
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( !entries[i].desc || entries[i].flags & FD_CLOFORK )
|
2014-08-20 18:02:37 -04:00
|
|
|
{
|
2015-09-19 13:37:31 -04:00
|
|
|
//ret->entries[i].desc = NULL; // Constructor did this already.
|
|
|
|
ret->entries[i].flags = 0;
|
|
|
|
continue;
|
2014-08-20 18:02:37 -04:00
|
|
|
}
|
2015-09-19 13:37:31 -04:00
|
|
|
ret->entries[i] = entries[i];
|
2021-12-17 18:05:46 -05:00
|
|
|
ret->entries_used++;
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( ret->first_not_taken == i )
|
|
|
|
ret->first_not_taken = i + 1;
|
2012-08-07 18:19:44 -04:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<Descriptor> DescriptorTable::Get(int index)
|
|
|
|
{
|
|
|
|
ScopedLock lock(&dtablelock);
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( !IsGoodEntry(index) )
|
|
|
|
return errno = EBADF, Ref<Descriptor>(NULL);
|
2012-08-07 18:19:44 -04:00
|
|
|
return entries[index].desc;
|
|
|
|
}
|
|
|
|
|
2021-12-17 18:05:46 -05:00
|
|
|
// Expands the table to have at least need_entries entries and at least
|
|
|
|
// need_unused unused entries.
|
|
|
|
bool DescriptorTable::Enlargen(int need_entries,
|
|
|
|
int need_unused) // dtablelock taken
|
2012-08-07 18:19:44 -04:00
|
|
|
{
|
2021-12-17 18:05:46 -05:00
|
|
|
// Figure out how many entries are needed to satisfy the need for unused
|
|
|
|
// entries and grow the entries to that size if larger than need_entries.
|
|
|
|
if ( __builtin_add_overflow(need_unused, entries_used, &need_unused) ||
|
|
|
|
__builtin_add_overflow(need_unused, reserved_count, &need_unused) )
|
|
|
|
return errno = EMFILE, false;
|
|
|
|
if ( need_entries < need_unused )
|
|
|
|
need_entries = need_unused;
|
|
|
|
if ( need_entries <= entries_length )
|
|
|
|
return true;
|
|
|
|
if ( entries_length == INT_MAX )
|
|
|
|
return errno = EMFILE, false;
|
|
|
|
// At least double the size of the table but maybe more entries are needed.
|
|
|
|
int new_entries_length = 8;
|
|
|
|
if ( entries_length &&
|
|
|
|
__builtin_mul_overflow(2, entries_length, &new_entries_length) )
|
|
|
|
new_entries_length = INT_MAX;
|
|
|
|
if ( new_entries_length < need_entries )
|
|
|
|
new_entries_length = need_entries;
|
|
|
|
DescriptorEntry* new_entries = new DescriptorEntry[new_entries_length];
|
|
|
|
if ( !new_entries )
|
2012-08-07 18:19:44 -04:00
|
|
|
return false;
|
2021-12-17 18:05:46 -05:00
|
|
|
for ( int i = 0; i < entries_length; i++ )
|
2015-09-19 13:37:31 -04:00
|
|
|
{
|
2021-12-17 18:05:46 -05:00
|
|
|
new_entries[i] = entries[i];
|
2015-09-19 13:37:31 -04:00
|
|
|
entries[i].desc.Reset();
|
|
|
|
}
|
2021-12-17 18:05:46 -05:00
|
|
|
for ( int i = entries_length; i < new_entries_length; i++ )
|
2015-09-19 13:37:31 -04:00
|
|
|
{
|
2021-12-17 18:05:46 -05:00
|
|
|
//new_entries[i].desc = NULL; // Constructor did this already.
|
|
|
|
new_entries[i].flags = 0;
|
2015-09-19 13:37:31 -04:00
|
|
|
}
|
|
|
|
delete[] entries;
|
2021-12-17 18:05:46 -05:00
|
|
|
entries = new_entries;
|
|
|
|
entries_length = new_entries_length;
|
2012-08-07 18:19:44 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-12-17 18:05:46 -05:00
|
|
|
bool DescriptorTable::Reserve(int count, int* reservation)
|
|
|
|
{
|
|
|
|
assert(0 <= count);
|
|
|
|
if ( !Enlargen(0, count) )
|
|
|
|
return false;
|
|
|
|
assert(reserved_count <= entries_length - entries_used);
|
|
|
|
assert(reserved_count + count <= entries_length - entries_used);
|
|
|
|
reserved_count += count;
|
|
|
|
*reservation = count;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DescriptorTable::Unreserve(int* reservation)
|
|
|
|
{
|
|
|
|
assert(0 <= *reservation);
|
|
|
|
assert(*reservation <= reserved_count);
|
|
|
|
reserved_count -= *reservation;
|
|
|
|
*reservation = 0;
|
|
|
|
}
|
|
|
|
|
2015-09-19 13:37:31 -04:00
|
|
|
int DescriptorTable::AllocateInternal(Ref<Descriptor> desc,
|
|
|
|
int flags,
|
2021-12-17 18:05:46 -05:00
|
|
|
int min_index,
|
|
|
|
int* reservation) // dtablelock locked
|
2012-08-07 18:19:44 -04:00
|
|
|
{
|
2021-12-17 18:05:46 -05:00
|
|
|
assert(!reservation || 1 <= *reservation);
|
|
|
|
assert(!reservation || !min_index);
|
2012-08-07 18:19:44 -04:00
|
|
|
if ( flags & ~__FD_ALLOWED_FLAGS )
|
|
|
|
return errno = EINVAL, -1;
|
2013-09-24 07:14:18 -04:00
|
|
|
if ( min_index < 0 )
|
|
|
|
return errno = EINVAL, -1;
|
2014-08-20 18:02:37 -04:00
|
|
|
if ( min_index < first_not_taken )
|
|
|
|
min_index = first_not_taken;
|
2021-12-17 18:05:46 -05:00
|
|
|
int first_available = min_index;
|
|
|
|
for ( int i = min_index; i < entries_length; i++ )
|
2014-08-20 18:02:37 -04:00
|
|
|
{
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( entries[i].desc )
|
2021-12-17 18:05:46 -05:00
|
|
|
{
|
|
|
|
if ( first_available == i )
|
|
|
|
first_available = i + 1;
|
|
|
|
if ( first_not_taken == i )
|
|
|
|
first_not_taken = i + 1;
|
2015-09-19 13:37:31 -04:00
|
|
|
continue;
|
2021-12-17 18:05:46 -05:00
|
|
|
}
|
|
|
|
if ( !reservation && entries_length - reserved_count <= i )
|
|
|
|
break;
|
2015-09-19 13:37:31 -04:00
|
|
|
entries[i].desc = desc;
|
|
|
|
entries[i].flags = flags;
|
2021-12-17 18:05:46 -05:00
|
|
|
entries_used++;
|
|
|
|
if ( reservation )
|
|
|
|
{
|
|
|
|
assert(reserved_count);
|
|
|
|
(*reservation)--;
|
|
|
|
reserved_count--;
|
|
|
|
}
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( first_not_taken == i )
|
|
|
|
first_not_taken = i + 1;
|
|
|
|
return i;
|
2014-08-20 18:02:37 -04:00
|
|
|
}
|
2021-12-17 18:05:46 -05:00
|
|
|
assert(!reservation);
|
|
|
|
if ( !Enlargen(first_available + 1, 1) )
|
2012-08-07 18:19:44 -04:00
|
|
|
return -1;
|
2021-12-17 18:05:46 -05:00
|
|
|
entries[first_available].desc = desc;
|
|
|
|
entries[first_available].flags = flags;
|
|
|
|
entries_used++;
|
|
|
|
if ( first_not_taken == first_available )
|
|
|
|
first_not_taken = first_available + 1;
|
|
|
|
return first_available;
|
2012-08-07 18:19:44 -04:00
|
|
|
}
|
|
|
|
|
2021-12-17 18:05:46 -05:00
|
|
|
int DescriptorTable::Allocate(Ref<Descriptor> desc, int flags, int min_index,
|
|
|
|
int* reservation)
|
2013-09-24 07:14:18 -04:00
|
|
|
{
|
|
|
|
ScopedLock lock(&dtablelock);
|
2021-12-17 18:05:46 -05:00
|
|
|
return AllocateInternal(desc, flags, min_index, reservation);
|
2013-09-24 07:14:18 -04:00
|
|
|
}
|
|
|
|
|
2021-12-17 18:05:46 -05:00
|
|
|
int DescriptorTable::Allocate(int src_index, int flags, int min_index,
|
|
|
|
int* reservation)
|
2013-09-24 07:14:18 -04:00
|
|
|
{
|
|
|
|
ScopedLock lock(&dtablelock);
|
|
|
|
if ( !IsGoodEntry(src_index) )
|
|
|
|
return errno = EBADF, -1;
|
2021-12-17 18:05:46 -05:00
|
|
|
return AllocateInternal(entries[src_index].desc, flags, min_index,
|
|
|
|
reservation);
|
2013-09-24 07:14:18 -04:00
|
|
|
}
|
|
|
|
|
2013-09-23 14:41:31 -04:00
|
|
|
int DescriptorTable::Copy(int from, int to, int flags)
|
2012-08-07 18:19:44 -04:00
|
|
|
{
|
2013-09-23 14:41:31 -04:00
|
|
|
if ( flags & ~__FD_ALLOWED_FLAGS )
|
|
|
|
return errno = EINVAL, -1;
|
2012-08-07 18:19:44 -04:00
|
|
|
ScopedLock lock(&dtablelock);
|
2022-02-09 03:08:06 -05:00
|
|
|
if ( !IsGoodEntry(from) || to < 0 )
|
2012-08-07 18:19:44 -04:00
|
|
|
return errno = EBADF, -1;
|
2013-09-23 14:41:31 -04:00
|
|
|
if ( from == to )
|
|
|
|
return errno = EINVAL, -1;
|
2021-12-17 18:05:46 -05:00
|
|
|
if ( to == INT_MAX )
|
|
|
|
return errno = EBADF, -1;
|
|
|
|
if ( !IsGoodEntry(to) && !Enlargen(to + 1, 1) )
|
|
|
|
return -1;
|
2012-08-07 18:19:44 -04:00
|
|
|
if ( entries[to].desc != entries[from].desc )
|
|
|
|
{
|
2021-12-17 18:05:46 -05:00
|
|
|
if ( !entries[to].desc )
|
|
|
|
entries_used++;
|
2012-08-07 18:19:44 -04:00
|
|
|
entries[to].desc = entries[from].desc;
|
|
|
|
}
|
2013-09-23 14:41:31 -04:00
|
|
|
entries[to].flags = flags;
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( first_not_taken == to )
|
|
|
|
first_not_taken = to + 1;
|
2012-08-07 18:19:44 -04:00
|
|
|
return to;
|
|
|
|
}
|
|
|
|
|
2015-05-13 11:48:53 -04:00
|
|
|
Ref<Descriptor> DescriptorTable::FreeKeepInternal(int index)
|
2021-12-17 18:05:46 -05:00
|
|
|
// dtablelock locked
|
2012-08-07 18:19:44 -04:00
|
|
|
{
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( !IsGoodEntry(index) )
|
|
|
|
return errno = EBADF, Ref<Descriptor>(NULL);
|
2012-08-07 18:19:44 -04:00
|
|
|
Ref<Descriptor> ret = entries[index].desc;
|
|
|
|
entries[index].desc.Reset();
|
2015-09-19 13:37:31 -04:00
|
|
|
entries[index].flags = 0;
|
2021-12-17 18:05:46 -05:00
|
|
|
entries_used--;
|
2014-08-20 18:02:37 -04:00
|
|
|
if ( index < first_not_taken )
|
|
|
|
first_not_taken = index;
|
2012-08-07 18:19:44 -04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-05-13 11:48:53 -04:00
|
|
|
Ref<Descriptor> DescriptorTable::FreeKeep(int index)
|
|
|
|
{
|
|
|
|
ScopedLock lock(&dtablelock);
|
|
|
|
return FreeKeepInternal(index);
|
|
|
|
}
|
|
|
|
|
2012-08-07 18:19:44 -04:00
|
|
|
void DescriptorTable::Free(int index)
|
|
|
|
{
|
|
|
|
FreeKeep(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DescriptorTable::OnExecute()
|
|
|
|
{
|
|
|
|
ScopedLock lock(&dtablelock);
|
2021-12-17 18:05:46 -05:00
|
|
|
for ( int i = 0; i < entries_length; i++ )
|
2012-08-07 18:19:44 -04:00
|
|
|
{
|
|
|
|
if ( !entries[i].desc )
|
|
|
|
continue;
|
|
|
|
if ( !(entries[i].flags & FD_CLOEXEC) )
|
|
|
|
continue;
|
|
|
|
entries[i].desc.Reset();
|
2014-08-20 18:02:37 -04:00
|
|
|
if ( i < first_not_taken )
|
|
|
|
first_not_taken = i;
|
2021-12-17 18:05:46 -05:00
|
|
|
entries_used--;
|
2012-08-07 18:19:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DescriptorTable::SetFlags(int index, int flags)
|
|
|
|
{
|
|
|
|
if ( flags & ~__FD_ALLOWED_FLAGS )
|
2015-09-19 13:37:31 -04:00
|
|
|
return errno = EINVAL, false;
|
2012-08-07 18:19:44 -04:00
|
|
|
ScopedLock lock(&dtablelock);
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( !IsGoodEntry(index) )
|
|
|
|
return errno = EBADF, false;
|
2012-08-07 18:19:44 -04:00
|
|
|
entries[index].flags = flags;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DescriptorTable::GetFlags(int index)
|
|
|
|
{
|
|
|
|
ScopedLock lock(&dtablelock);
|
2015-09-19 13:37:31 -04:00
|
|
|
if ( !IsGoodEntry(index) )
|
|
|
|
return errno = EBADF, -1;
|
2012-08-07 18:19:44 -04:00
|
|
|
return entries[index].flags;
|
|
|
|
}
|
|
|
|
|
2014-08-09 06:29:35 -04:00
|
|
|
int DescriptorTable::Previous(int index)
|
|
|
|
{
|
|
|
|
ScopedLock lock(&dtablelock);
|
|
|
|
if ( index < 0 )
|
2021-12-17 18:05:46 -05:00
|
|
|
index = entries_length;
|
2014-08-09 06:29:35 -04:00
|
|
|
do index--;
|
|
|
|
while ( 0 <= index && !IsGoodEntry(index) );
|
|
|
|
if ( index < 0 )
|
|
|
|
return errno = EBADF, -1;
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DescriptorTable::Next(int index)
|
|
|
|
{
|
|
|
|
ScopedLock lock(&dtablelock);
|
|
|
|
if ( index < 0 )
|
|
|
|
index = -1;
|
2021-12-17 18:05:46 -05:00
|
|
|
if ( entries_length <= index )
|
2014-08-09 06:29:35 -04:00
|
|
|
return errno = EBADF, -1;
|
|
|
|
do index++;
|
2021-12-17 18:05:46 -05:00
|
|
|
while ( index < entries_length && !IsGoodEntry(index) );
|
|
|
|
if ( entries_length <= index )
|
2014-08-09 06:29:35 -04:00
|
|
|
return errno = EBADF, -1;
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2015-05-13 11:48:53 -04:00
|
|
|
int DescriptorTable::CloseFrom(int index)
|
|
|
|
{
|
|
|
|
if ( index < 0 )
|
|
|
|
return errno = EBADF, -1;
|
|
|
|
ScopedLock lock(&dtablelock);
|
|
|
|
bool any = false;
|
2021-12-17 18:05:46 -05:00
|
|
|
for ( ; index < entries_length; index++ )
|
2015-05-13 11:48:53 -04:00
|
|
|
{
|
|
|
|
if ( !IsGoodEntry(index) )
|
|
|
|
continue;
|
|
|
|
FreeKeepInternal(index);
|
|
|
|
any = true;
|
|
|
|
}
|
|
|
|
return any ? 0 : (errno = EBADF, -1);
|
|
|
|
}
|
|
|
|
|
2012-08-07 18:19:44 -04:00
|
|
|
} // namespace Sortix
|