Go to the FreeLists Home Page Home Signup Help Login
 



[openbeosstorage] || [Date Prev] [04-2002 Date Index] [Date Next] || [Thread Prev] [04-2002 Thread Index] [Thread Next]

[openbeosstorage] BDirectory update

  • From: Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
  • To: openbeosstorage@xxxxxxxxxxxxx
  • Date: Tue, 16 Apr 2002 19:15:49 +0200 (MET DST)
Hello guys,

it's me again. :-)
I checked in my BDirectory implementation and some fixes to the tests
to make it pass them. The implementation is more or less complete, but
some polishing is still to be done. But I will postpone this until more
complete BEntry and BPath implementations are available.

Due to a misunderstanding I did the same StorageKit::Dir->FileDesriptor
substitution Tyler did. I replaced most of the concerned kernel interface
functions with my versions. I didn't touch the attribute directory
functions and for most of the others only the implementation might be
slightly different.

However, some of them, namely read_dir() and find_dir(), have different
parameters now. They don't allocate a buffer for the dirent(s) for the
caller, but expect one to be passed instead. This avoids unnecessary
copying, or more precisly, will avoid it when the kernel interface becomes
a real kernel interface.

For convenience I added a class LongDirEntry, that provides a buffer big
enough to store one entry and can be used like this:

  StorageKit::LongDirEntry entry;
  if (find_dir(..., &entry, sizeof(entry)) == B_OK) {
    printf("name: %s\n", entry.d_name);
    ...
  }

Furthermore I added the functions create_dir(), create_link(),
get_canonical_path() and is_path_absolute(). The first two have the
obvious semantics.
get_canonical_path() takes a path and returns a canonical version of it.
As I noticed later, it does exactly, what the normalization feature of
BPath is supposed to do, i.e. it requires the supplied path to be an
(possibly abstract) entry in an existing directory and does conversions
like those:

  /boot/./home/config/..  ->  /boot/home
  /tmp/non-existing       ->  /boot/var/tmp/non-existing

is_path_absolute() tells you whether you have supplied an absolute path.
As I realize now, this function does not really belong to the kernel
interface. I will move it to storage_support.cpp/h as soon as I have
finished this mail.

storage_support.* already contains a function named split_path(), which
takes a path name and splits it into directory path and leaf name. BTW,
the implementation has been stolen from Entry.cpp. ;-)

All those nice things have been checked in. Before I did, I tagged the
previous head version with "pre-BDirectory-impl", just in case any
problems with my kernel interface changes might occur.

BTW, while testing BDirectory I realized, that BEntry (or perhaps
underlying kernel interface functions) do not deal correctly with too long
path/entry names and cyclic links.

That's all so far. My next victim will be BSymLink.

CU, Ingo






[ Home | Signup | Help | Login | Archives | Lists ]

All trademarks and copyrights within the FreeLists archives are owned by their respective owners.
Everything else ©2007 Avenir Technologies, LLC.