Commit Graph

5504 Commits

Author SHA1 Message Date
Ingo Weinhold
2fdd1d9ef1 khash: Move string hash functions to own header/source file
Unlike khash they shouldn't be phased out (only renamed).
2013-11-19 15:08:34 +01:00
Ingo Weinhold
efe9df3791 driver settings: Add load_driver_settings_file()
Allows loading an already opened driver settings file (by FD).
2013-11-19 15:06:30 +01:00
Ingo Weinhold
cf09345cf5 driver settings: Remove dead load_driver_settings_from_path()
load_driver_settings() supports being passed an absolute path.
2013-11-19 14:02:21 +01:00
Ingo Weinhold
81522ad41b find_path_for_path_etc(): Fail for B_FIND_PATH_IMAGE_PATH
There's no image in this case. We would just return the path we were
given.
2013-11-19 02:05:35 +01:00
Ingo Weinhold
22e92014f0 s/B_FIND_PATH_IMAGE_PACKAGE_PATH/B_FIND_PATH_PACKAGE_PATH/
It doesn't only work for image files, so make the name more general.
2013-11-19 02:05:35 +01:00
Ingo Weinhold
94fb954c53 find_path*(): Support user specific home directory
No longer hard-code the home directory path. Instead ask
find_directory(), so we get the correct one for the current user.
2013-11-18 01:50:49 +01:00
Ingo Weinhold
04c6cb37bb find_directory(): Add architecture support
* Move PathBuffer helper class out of find_paths.cpp into its own
  header.
* find_directory():
  - Make use of MemoryDeleter to simplify things.
  - Make use of PathBuffer for a simpler and more correct handling.
  - Make B_UTILITIES_DIRECTORY to B_APPS_DIRECTORY. /boot/utilities
    doesn't exist anyway.
  - Resolve the concerned constants to the architecture specific
    subdirectory, when called in a secondary architecture context, just
    like find_path*().
2013-11-17 19:11:03 +01:00
Ingo Weinhold
7fb0d6c269 find_path*(): Fix B_FIND_PATH_MEDIA_NODES_DIRECTORY
It is architecture specific as well.
2013-11-17 19:11:02 +01:00
Ingo Weinhold
8a3fe6d1bf Add private __getenv_reentrant()
A reentrant variant of getenv().
2013-11-17 19:11:02 +01:00
Ingo Weinhold
c39c9283aa Add get_architectures() and C++ versions
* get_architectures() returns the primary and the secondary
  architectures in one array. That turned out to be convenient.
* Add C++ versions for get[_secondary]_architectures(), returning a
  BStringList.
2013-11-17 02:09:37 +01:00
Ingo Weinhold
60b39cd741 Add get_*architecture() API, extend find_path*() API
* Add get_architecture(), get_primary_architecture(),
  get_secondary_architectures(), guess_architecture_for_path() to get
  the caller's architecture, the primary architecture, all secondary
  architectures, or the architecture associated with a specified path
  respectively.
* Rename the find_path*() functions to find_path*_etc() and add an
  optional architecture parameter. Add simplified find_path*()
  functions.
* BPathFinder: Add FindPath[s]() versions with an architecture
  parameter.
2013-11-17 02:09:36 +01:00
Ingo Weinhold
cf7e2ad812 runtime loader: Export get_executable_architecture() function
Given a path of an ELF file, it tries to determine its architecture.
2013-11-17 02:09:36 +01:00
Axel Dörfler
04da290fd6 Minor cleanup. 2013-11-15 23:13:54 +01:00
Ingo Weinhold
2b269f2e47 unlock_memory_etc(): Fix address space reference leak
unlock_memory_etc() is supposed to release the address space reference
lock_memory_etc() acquired. It didn't do that, though.
2013-11-13 01:47:36 +01:00
Ingo Weinhold
93fb0ff056 vm: lock_memory_etc(): Fix error case
In case something went wrong, call unlock_memory_etc() with the rounded
base address instead of with the original address. If the original
address wasn't page aligned, unlock_memory_etc() would otherwise try to
unlock an additional page.
2013-11-13 01:47:35 +01:00
Ingo Weinhold
104c0688da dir_vnode_to_path(): Fix uninitialized status variable 2013-11-11 23:04:09 +01:00
Ingo Weinhold
24d0e21f51 do_iterative_fd_io_iterate(): Support sparse files
* Check whether the vectors we get are sparse file vectors and satisfy
  them immediately instead of creating a subrequest. Untested, since the
  API isn't used by ext2 as it should be.
* Add error == B_OK to the condition of the outer loop.
2013-11-11 22:27:53 +01:00
Ingo Weinhold
9f7e78ee79 IORequest::Init(): Assert offset >= 0
Just to make sure we catch sparse file vectors that shouldn't be passed
here.
2013-11-11 22:27:53 +01:00
Ingo Weinhold
c63b3de665 IORequest: Add ClearData() 2013-11-11 22:27:53 +01:00
Ingo Weinhold
426fe7db1d IORequest::_CopyData(): Small optimization
If we're running in the context of the user team the I/O buffer belongs
to, we can use _CopySimple() as well.
2013-11-11 22:27:53 +01:00
Ingo Weinhold
07f6506eb6 VFS: Fix broken zero_pages()
Besides that it failed to actually iterate through the vectors, it
shouldn't try to clear physical memory in the first place. The iovecs
refer to virtual address ranges. Rename it to zero_iovecs() to avoid
confusion.
2013-11-11 22:27:52 +01:00
Ingo Weinhold
e5f6591382 VM: vm_memset_physical(): Correct length parameter type 2013-11-11 22:27:52 +01:00
Jérôme Duval
e94bffa072 vm: allocate wrappers on the heap with small stack array fallback
see comments on #10169. Thanks Ingo for reviewing!
2013-11-11 18:34:14 +01:00
Olivier Coursière
be6d2f97cd libroot: Accept NULL for the resolved_name argument of realpath()
as specified in IEEE Std 1003.1, 2013 Edition, see
http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html

In this case, the returned buffer is allocated with realpath() and can be
deallocated by the caller with free().
The behavior was only "implementation defined" in previous revisions like
IEEE Std 1003.1, 2004 Edition, see
http://pubs.opengroup.org/onlinepubs/000095399/functions/realpath.html

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2013-11-10 23:26:18 +01:00
Ingo Weinhold
18640f25d9 vfs: dir_vnode_to_path(): Fix bug with chroot on mount
Simplify the code, which also fixes the bug that the I/O context's root
was ignored when it was a mount point, thus resulting in globally rooted
paths in this case.
2013-11-10 15:43:43 +01:00
Jérôme Duval
7f0b39a791 CID 991479 Out-of-bounds access 2013-11-09 13:40:07 +01:00
Ingo Weinhold
986e4abce4 Add new API find_path[s](), find_path_for_path()
The new functions are meant to replace many uses of find_directory():
* find_paths() is supposed to be used when the directories of a certain
  kind in all installation directories are needed (e.g. font
  directories, add-on directory, etc.). Using this API makes code
  robust wrt addition or removal of installation locations.
* find_path() is supposed to be used when files/directories associated
  with a loaded program, library, or add-on need to be found (e.g. data
  files or global settings).
* find_path_for_path() is similar to find_path(), but it starts from a
  given path instead of an image.
2013-11-05 21:40:43 +01:00
François Revol
0e1c6462de Merge branch 'sam460ex' 2013-11-04 17:04:49 +01:00
Ingo Weinhold
fdaba7aaa5 Skip boot device check sum test on CD boot
Whatever we read from the drive in the boot loader isn't what we can
read from the device later, so rather skip the check sum test for
identifying the boot device in the kernel when booting off CD. Fixes
#10147.
2013-10-28 01:18:23 +01:00
François Revol
b3025a8642 bootloader: M68K: Fix mmu_free()
Same bug as in ARM code...
2013-10-26 20:54:12 +02:00
François Revol
585830a55e bootloader: M68K: s/KERNEL_BASE/KERNEL_LOAD_BASE/ 2013-10-26 20:54:11 +02:00
François Revol
b086b8ad2d bootloader: ARM: Replace KERNEL_BASE with KERNEL_LOAD_BASE 2013-10-26 20:54:10 +02:00
François Revol
18041782fd bootloader: ARM: Fix mmu_free()
Allocation size was mixed up with page counts...
Allow freeing up to sNextVirtualAddress.
2013-10-26 20:54:00 +02:00
François Revol
9703c9cc30 bootloader: Add tracing to malloc_large() 2013-10-26 18:41:57 +02:00
Julian Harnath
7f64b301b1 Reduce lock contention in kernel port subsystem.
* Replace ports list mutex with R/W-lock.

* Move team port list protection to separate array of mutexes.
  Relieve contention on sPortsLock by removing Team::port_list from its
  protected items. With this, set_port_owner() only needs to acquire the
  sPortsLock for reading.

* Add another hash table holding the ports by name. Used by find_port()
  so it doesn't have to iterate over the list anymore.

* Use slab-based memory allocator for port messages. sPortQuotaLock was
  acquired on every message send or receive and was thus another point
  of contention. The lock is not necessary anymore.

* Lock for port hashes and Port::lock are no longer locked in a nested
  fashion to reduce chances of blocking other threads.

* Make operations concurrency-safe by adding an atomically accessed
  Port::state which provides linearization points to port creation and
  deletion. Both operations are now divided into logical and physical
  parts, the logical part just updating the state and the physical part
  adding/remove it to/from the port hash and team port list.

* set_port_owner() is the only remaining function which still locks
  Port::lock and one or two of sTeamListLock[] in a nested fashion.
  Since it needs to move the port from one team list to another and
  change Port::owner, there's no way around.

* Ports are now reference counted to make accesses to already-deleted
  ports safe.

* Should fix #8007.
2013-10-26 16:10:03 +02:00
Ingo Weinhold
a3a4302bea boot loader heap: Handle large allocations separately
Use platform_{allocate,free}_region() to allocate/free chunks >= 16 KiB.
This reduces the usage of our dedicated (and limited) heap region,
particularly since packagefs makes some larger temporary allocations
while reading the package file. Should fix #10136.
2013-10-26 05:10:16 +02:00
Ingo Weinhold
6ef9697b00 boot loader: packagefs: Fix memory leak on unmount
The PackageNodes weren't destroyed.
2013-10-26 05:03:55 +02:00
Ingo Weinhold
7b1dee3929 boot loader: Fix find_unique_check_sums()
Comparing the complete disk_identifer structure isn't helpful as long as
we don't (can't) compare it in the kernel as well. ATM we only check the
check sums there, so that's what we need to do here as well. This fixes
potential mix-ups when booting off one of multiple equally sized disks.
2013-10-26 02:48:18 +02:00
Ingo Weinhold
63d56be3d9 boot loader: BootVolume::SetTo(): Fix reference counting
We release the reference for fRootDirectory in Unset() but never
acquired one. Fixes crash when selecting a boot volume in the menu.
2013-10-26 01:44:11 +02:00
Jérôme Duval
2bd8cdc16b acpi: switch acpi_object from a struct to a union
* this way the size of acpi_object_type matches the size of ACPI_OBJECT
for 32-bit and 64-bit builds.
* adjust users of the type acpi_object_type.
2013-10-24 14:29:47 +02:00
François Revol
4c7a310ce1 OF: PPC: Check for bus-frequency on '/' first
As per PowerPC IEEE 1275-1994 binding v1.8 page 13.
2013-10-20 20:53:06 +02:00
François Revol
b96e57e885 Fix typo 2013-10-19 16:06:41 +02:00
François Revol
7cbc41ae32 U-Boot: Split fdt_support.cpp, move serial stuff to fdt_serial.cpp 2013-10-15 23:05:09 +02:00
François Revol
3f92e864a1 Style fixes 2013-10-15 22:17:55 +02:00
François Revol
b55cb439e7 U-Boot: pass around argv and /chosen/bootargs
Not really handled correctly yet, but at least they are passed.
2013-10-15 22:15:04 +02:00
François Revol
cf7f92c013 bootloader: Use stage2_args:arguments_count
The code probably doesn't work correctly yet though,
I believe only the last line will be taken into account.
2013-10-15 22:15:04 +02:00
François Revol
70b50f3865 bootloader: Set stage2_args:arguments_count when needed 2013-10-15 22:15:03 +02:00
François Revol
8fa75a8cca ARM: Add a fallback atomic_add() for bootloader
When ATOMIC_FUNCS_ARE_SYSCALLS atomic.S doesn't export it,
but it's used by packagefs.
2013-10-12 19:43:33 +02:00
Oliver Tappe
8b08992799 Implement shebang-fixup for /usr/bin/env to runtime_loader.
* silently replace invocations /usr/bin/env with /bin/env
2013-10-11 13:00:33 +02:00
Ingo Weinhold
28fcae227c Stage 1 boot loader: Load the first file matching haiku_loader*
This allows naming the boot loader package canoncically. Due to code
size limitations we cannot perform a more correct name check, but there
shouldn't be any other entries in the packages directory with a name
with "haiku_loader" prefix, anyway.
2013-10-10 00:40:10 +02:00