Commit Graph

42 Commits

Author SHA1 Message Date
Michael Lotz 14429e896e Reverted the part of r31520 that made devfs_unpublish_partition() take a raw
device path + child partition name. When a "raw" device is unpublished the node
removal notification triggers the partition and child partitions to be
unpublished/removed. Since in that case the "raw" node is already unpublished
trying to resolve it in devfs_unpublish_partition() again to unpublish the child
partitions would fail, leaving the child partition nodes behind. When a new raw
device would then become available publishing its partitions would fail because
of these left behind nodes, causing bug #4587. Seeing that this code is more
compact and straight forward anyway I don't quite see why it was changed in the
first place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34967 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-01-09 03:55:38 +00:00
Ingo Weinhold a365e1cfbb Patch by Bryce Groff, some changes by myself:
* devfs:
  - devfs_[un]publish_partition(): They no longer get the partition path as
    parameter, but rather the device path and the partition name.
  - Added devfs_rename_partition(), which renames an already published
    partition node.
* KPartition/KDiskDevice:
  - Replaced the fPublished flag by fPublishedName, the name under which the
    partition is published. This simplifies UnpublishDevice() and makes it
    practically infallible.
  - Added GetFileName(), which only returns the partition's file name.
    Simplified GetPath() by using it.
  - When a partition is added/removed the subsequent sibling partitions get a
    new index. Now we also rename their published device nodes (and those of
    their descendents). When something goes wrong we unpublish the concerned
    partition's device to be on the safe side. Would be a shame to accidentally
    format the wrong partition, eh? :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31520 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-11 14:35:04 +00:00
Ingo Weinhold b538ceb816 Added dup_foreign_fd() to duplicate a FD from another team.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29468 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-03-11 00:57:17 +00:00
Ingo Weinhold e8d3eff968 * vfs_normalize_path() and _user_normalize_path() use a common helper
function (normalize_path()), now. There was some code duplication
  before.
* Added "bool traverseLink" parameter to vfs_normalize_path(). When
  true and the leaf component is a symlink, it will be resolved.
* KPath:
  - Added similar leaf link traversal parameter to SetTo() and
    SetPath().
  - Added Normalize().
  - Added DetachBuffer(), which returns the object's current buffer and
    unsets itself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27751 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-09-26 23:30:28 +00:00
Axel Dörfler 191a03fd11 * {add|remove}_node_listener() erroneously had "dev_t" as type of "node".
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26340 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-07-09 13:04:54 +00:00
Axel Dörfler 368167ede8 * Integration of the new driver architecture.
* Moved devfs from fs/ to device_manager/, and separated the legacy driver
  support from it.
* Removed fast_log module.
* There are a couple of (temporary) regressions, though:
  - legacy SATA and ISA IDE support is disabled, the drivers haven't been
    ported yet.
  - The not yet used ATA bus manager hasn't been ported yet, either.
  - AHCI changes have not been tested.
  - the listdev command has been removed from the build (as it currently
    doesn't work anymore).
  - device manager generated IDs currently are not freed anymore when a device
    node is removed.
  - generic drivers can't yet use the new driver architecture.
  - simple busses that do not support device types won't work yet.
  - legacy driver publishing/unpublishing (ie. what USB needs) has not been
    tested, and may be broken.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25662 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-05-26 16:52:27 +00:00
Axel Dörfler 56bbbbc9ca * Added Adopt() method that steals the other path's buffer.
* Fixed operator=(): the second argument of SetTo() is a boolean (normalize),
  not the length of the buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25382 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-05-08 16:45:29 +00:00
Ingo Weinhold cb734beeee Added get_open_fd() function which gets the descriptor and also
increments its open count.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25317 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-05-05 00:24:14 +00:00
Ingo Weinhold 0cc82d47d4 Added close_fd_index() which is pretty much like close(), but gets the
IO context in which to close the FD.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24937 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-04-12 08:32:29 +00:00
Ingo Weinhold 3118b3a7cb * Added fd_ops::set_flags() hook. It's only implemented by socket FDs
ATM.
* Changed common_fcntl() to also work for non-vnode-based FDs. Only the
  operations that require a vnode do fail now. F_SETFL uses the new
  fd_ops::set_flags() if available, falling back to the vnode respective
  operation.
* Changed some direct accesses to file_descriptor::u::vnode. It was safe
  in those cases, but might not be anymore if we ever change fd_vnode().

ftp can at least connect to servers again, now, but apparently we still
have a problem with syscall restarts -- downloads fail after one second,
when the timer goes off.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24917 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-04-11 19:21:14 +00:00
Ingo Weinhold 3cc3dcb385 Preparation for socket file descriptors.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24905 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-04-11 03:33:59 +00:00
Ingo Weinhold 360be1fc45 * Implemented support for chroot:
- Added a "root" vnode to the io_context. It is used for resolving
    paths and converting nodes to paths instead of sRoot. Some more
    passing around of io_context structures was necessary.
  - Introduced a new lock sIOContextRootLock to protect
    io_context::root. The current uses of io_context::io_mutex
    (put_vnode(), remove_vnode() while holding it) looked too suspicious
    to use that mutex in vnode_path_to_vnode().
  - Added _kern_change_root() syscall and chroot() libroot function.
  - Added chroot coreutils program to the image. Funnily it seems to be
    much easier to set up a little jail than under Linux (just copy
    bash and libroot.so into respective subdirs; mount another pipefs
    if you want pipe support).
    With Haiku allowing direct access to directories via inode IDs
    jailing is obviously not very secure at the moment.
  - Added /var/empty to the image. It will be the chroot target for ssh.
* Changed vfs.cpp:get_cwd() so that the io_context::io_mutex is no
  longer held when calling dir_vnode_to_path().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24673 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-03-30 05:59:54 +00:00
Axel Dörfler a77ed12b25 * Removed obsolete "ident" parameter from devfs_publish_device().
* driver_entry::api_version now stores the actual version instead of a
  pointer to it.
* Renamed node_path_entry to path_entry and reused it for driver 
  reloading: handle_driver_events() will now also check for drivers to
  add in the sDriversToAdd list.
* Added new devfs_driver_added(), and devfs_driver_removed() functions
  that trigger certain driver actions.
* Implemented notifying devfs on B_ENTRY_CREATED, B_ENTRY_REMOVED, and
  B_ENTRY_MOVED events in probe.cpp. The watched directory inode numbers
  are now stored in a hash for B_ENTRY_MOVED.
* unpublish_driver() did not actually delete the node, it only marked
  it removable since we never get/put the node. We now do, and so the
  node is actually removed as intended.
* Added "devfs_driver" KDL command.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24152 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-02-27 16:55:59 +00:00
Axel Dörfler 9448bb6e0b Added add_node_listener() and remove_node_listener() kernel private functions
to watch a node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24035 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-02-20 16:48:16 +00:00
Michael Lotz bbea21a256 Forgot the header change in the last commit.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23073 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-12-06 21:41:08 +00:00
Axel Dörfler d73d20e85c Fixed warning when compiling the PS/2 bus manager.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22615 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-10-18 17:23:14 +00:00
Ingo Weinhold 636bfc08ae * Renamed fs/vfs_select.cpp to wait_for_objects.cpp and got rid of
vfs_select.h, respectively moved most of it into the new kernel
  private header wait_for_objects.h.
* Added new experimental API functions wait_for_objects[_etc](). They
  work pretty much like poll(), but also for semaphores, ports, and
  threads.
* Removed the "ref" parameter from notify_select_events() and the
  select_sync_pool functions as well as from fd_ops::fd_[de]select(). It
  is no longer needed. The FS interface select() hook still has it,
  though -- the VFS will always pass 0.
* de]select_fd() take a select_info* instead of a select_sync* + ref
  pair, now. Added respective functions for semaphores, ports, and
  threads.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22416 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-10-02 19:47:31 +00:00
Ingo Weinhold 66c03dc3a9 * fd.c -> fd.cpp
* Reworked the select support:
  - The io_context additionally stores a table of lists of select_infos,
    which enables it to deselect events of a pending select() when
    closing a FD. This prevents a race condition potentially causing a
    write to stale memory.
  - The opaque selectsync* passed to FSs is now actually a select_info*.
    This was necessary, since the FDs deselect() hook (unlike the
    select() hook) doesn't take a "ref" argument and deselecting a
    single info (e.g. caused by a premature close()) was not possible.
    The select() hook's "ref" argument has become superfluous.
  - It should now be relatively easy to implement a poll_on_steroids()
    that can also wait for objects other than FDs (e.g. semaphores,
    ports, threads etc.). 
* Set/reset the signal mask in common_select(). This makes pselect()
  work as required.
* Reorganized vfs_resize_fd_table().



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22391 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-10-01 01:37:28 +00:00
Axel Dörfler edb15b5565 bonefish+axeld:
* Simplified the notification framework: removed the updater stuff completely;
  it was only there to account for some peculiarities of the node monitor which
  we now solved differently.
* NotificationListener no longer includes a doubly linked list link for convenience;
  it might want to listen to more than just one service.
* NotificationService cannot have an abstract destructor.
* Changed the _user_stop_watching() syscall to mirror the Be API; ie. it's no
  longer possible to just remove some flags separately, just to stop listening
  completely.
* Adapted the node monitor implementation to live in the NodeMonitorService class
  that uses the new notification framework.
* Removed the public kernel node monitor API - it wasn't useful that way since you
  couldn't do a lot with the KMessage in the kernel without using a private API.
  Now you will have to use the (private) notification manager to use the node monitor
  from inside the kernel. At a later point, we might introduce a public API for that,
  too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21780 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-08-01 14:48:44 +00:00
Ingo Weinhold 9e8dc2a9bb [Sorry, couldn't split this one up any further.]
* Images preloaded by the boot loader had to be modules to be of any use
  to the kernel. Extended the mechanism so that any images not accepted
  by the module code would later be tried to be added as drivers by the
  devfs. This is a little hacky ATM, since the devfs manages the drivers
  using a hash map keyed by the drivers inode ID, which those drivers
  obviously don't have.
* The devfs emulates read_pages() using read(), if the device driver
  doesn't implement the former (all old-style drivers), thus making it
  possible to BFS, which uses the file cache which in turn requires
  read_pages(), on the device. write_pages() emulation is still missing.
* Replaced the kernel_args::boot_disk structure by a KMessage, which can
  more flexibly be extended and deals more gracefully with
  arbitrarily-size data. The disk_identifier structure still exists,
  though. It is added as message field in cases where needed (non net
  boot). Moved the boot_drive_number field of the bios_ia32 platform
  specific args into the message.
* Made the stage 1 PXE boot loader superfluous. Moved the relevant
  initialization code into the stage 2 loader, which can now be loaded
  directly via PXE.
* The PXE boot loader does now download a boot tgz archive via TFTP. It
  does no longer use the RemoteDisk protocol (it could actually be
  removed from the boot loader). It also parses the DHCP options in the
  DHCPACK packet provided by PXE and extracts the root path to be
  mounted by the kernel.
* Reorganized the boot volume search in the kernel (vfs_boot.cpp) and
  added support for network boot. In this case the net stack is
  initialized and the network interface the boot loader used is brought
  up and configured. Since NBD and RemoteDisk are our only options for
  net boot (and those aren't really configurable dynamically) ATM, the
  the boot device is found automatically by the disk device manager.

Booting via PXE does work to some degree now. The most grievous problem
is that loading certain drivers or kernel modules (or related activity)
causes a reboot (likely a triple fault, though one wonders where our
double fault handler is on vacation). Namely the keyboard and mouse input
server add-ons need to be deactivated as well as the media server.
A smaller problem is the net server, which apparently tries to
(re-)configure the network interface we're using to boot, which
obviously doesn't work out that well. So, if all this stuff is disabled
Haiku does fully boot, when using the RemoteDisk protocol (not being
able to use keyboard or mouse doesn't make this a particular fascinating
experience, though ;-)). I had no luck with NBD -- it seemed to have
protocol problems with the servers I tried.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21611 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-15 02:10:15 +00:00
Ingo Weinhold 3532662e0c Added RemoveLeaf() leaf method. Very handy for recursive directory
iteration code using a single KPath object.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21606 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-07-15 00:34:17 +00:00
Axel Dörfler 245aecda8a Got rid of vnode_id and mount_id, replaced with ino_t and dev_t.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21485 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-06-21 19:50:57 +00:00
Hugo Santos 77bf99deb0 fixed the way accept() works in regards to the cookie pointer. It is no longer visible to userspace, we pass the fd instead. Also renamed kernel's shutdown() to system_shutdown as it collides with Posix's shutdown().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21223 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-05-23 19:56:40 +00:00
Axel Dörfler 606e0d364e * Factored out the vnode disconnection code from fs_unmount() to a separate
function, and added a vfs_disconnect_vnode() for other kernel components.
* devfs_unpublish_device() can now optionally make use of this call.
* Fixed the type check of devfs' unpublish_node().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16907 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-28 01:13:12 +00:00
Axel Dörfler 065aa7f66c Added a basic unpublishing function for drivers, not yet tested, though (and even
though it looks so simple, I see no reason why it shouldn't work 8-)).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16906 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-28 00:13:44 +00:00
Axel Dörfler 0d4c16e0c0 * Reduced the stack usage of most of the I/O paths - there were several places
that put one or more full paths on the stack before, which could cause some
  problems under certain conditions.
* Cleaned up KPath, ie. use size_t instead of int32 where appropriate, added
  license.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16585 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-05 18:11:59 +00:00
Axel Dörfler bb674499f8 * Finally implemented B_WATCH_MOUNT, ie. Tracker now shows newly mounted volumes
(mounting still only works from the Terminal).
* Shuffled functions in node_monitor.cpp around to clearly differentiate between
  private, private kernel, and public kernel functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16575 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-03 11:48:49 +00:00
Axel Dörfler ddb7d0b6a6 Implemented force unmounting - by passing the "-f" option to "unmount" you
can now safely unmount volumes that are still in use by some applications.
Minor fixes to the FD disconnection implementation:
* put_fd() checked the condition for being able to disconnect a descriptor
  incorrectly (causing the FD to never be disconnected).
* remove_fd() would hand out disconnected descriptors (but should have
  returned NULL for them).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15952 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-15 19:26:42 +00:00
Axel Dörfler 128165101a Implemented disconnecting file descriptors: this will be used by the
force unmounting code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15949 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-15 17:11:48 +00:00
Axel Dörfler d0d37bdfd1 * vfs_init() is now called later in the startup sequence - since no core kernel
service depends on it, it doesn't make any sense to call it that early in the
  game.
* The VFS now has a low memory handler for vnodes as well. If there is enough
  memory left, it won't free any vnodes anymore.
* Potential crashing bug fix: some functions did not check if the FD passed
  in belonged to the right type; they just assumed it had a valid vnode, but
  it could have had a mount structure associated as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15566 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-16 16:11:36 +00:00
Axel Dörfler 681779f1c8 Our close-on-exec flag handling was broken: it's supposed to be specified per slot, not
per file descriptor (a descriptor can be shared among several slots). There is now a
second table in the io_context structure that contains that information in a bitmap.
There are now two new (private) functions to control the close-on-exec flag, fd_close_on_exec(),
and fd_set_close_on_exec().
F_DUPFD, dup(), and dup2() are supposed to clear the close-on-exec flag on the duplicated
slot - this fixes bug #57 (no output after a redirect of a shell builtin).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14313 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-10-06 09:02:59 +00:00
Axel Dörfler 80f6ef8bd8 Moved load_driver() and load_driver_symbols() over to devfs.
Added new devfs_add_driver() function that the device manager will now call
to register new drivers.
Devfs will now keep a list of known drivers and remembers, if they have
been initialized already - a driver can now safely scan the directory it's
in while being scanned itself without having its hooks called twice.
Devfs is now using a recursive lock instead of a mutex (that's not really
a requirement right now, but would allow us to keep the fs lock during
scanning).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12933 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-06-02 18:32:21 +00:00
Ingo Weinhold 1cebd061c3 Added delete_select_sync_pool() to clean up.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11928 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-03-20 22:07:29 +00:00
Axel Dörfler 52fe8bf7a8 Minor header cleanup: moved some headers to better matching directories,
removed unused headers. Adapted sources to still compile with the new
header locations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11913 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-03-19 01:58:05 +00:00
Ingo Weinhold 63531836b9 * Added a small private API (<fs/select_sync_pool.h>) to support FSs
and drivers that need to provide special select() support with
  managing select notification information.
* Renamed vfs_select.c to *.cpp and fixed the resulting C++ compiler
  errors. Added tracing macros.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11886 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-03-17 21:27:01 +00:00
Axel Dörfler b38248e108 Fixed a warning in GCC 3.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9794 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-11-04 15:51:27 +00:00
Ingo Weinhold cba3b01fdf Added support for path normalization.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9625 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-10-28 22:16:41 +00:00
Ingo Weinhold 0402530222 Extended Append() to also allow adding parts of path components. Added leaf component manipulation. Now always chop trailing slashes off the path.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9560 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-10-28 15:09:48 +00:00
Ingo Weinhold d68a188e6d Added class KPath. Convenient wrapper for a fixed-sized path buffer.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9541 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-10-27 21:41:16 +00:00
Axel Dörfler bb45cbbb30 Removed some unneeded includes, making the header easier to swallow.
Renamed the image and node monitor syscalls to the new scheme.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8235 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-06-29 20:12:29 +00:00
Axel Dörfler 50ba16fccf Made C++ safe.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5075 a95241bf-73f2-0310-859d-f6bbb57e9c96
2003-10-17 14:42:45 +00:00
Axel Dörfler f9bdcca59c Added kernel private node_monitor.h header.
Moved definition of "struct io_context" from fd.h to vfs.h.
Introduced new fs/ directory; some cleanups to come.
Added node monitor syscalls.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2479 a95241bf-73f2-0310-859d-f6bbb57e9c96
2003-01-18 14:04:22 +00:00