summaryrefslogtreecommitdiff
path: root/libdiskfs
AgeCommit message (Collapse)Author
2023-12-17Update server handlers to return kern_return_error to fix ↵Flavio Cruz
-Werror=enum-int-mismatch warnings MiG expects those to return kern_return_t. Message-ID: <ZXqbbXpVqQAwd2qv@jupiter.tail36e24.ts.net>
2023-09-02S_dir_lookup: Handle O_DIRECTORYSamuel Thibault
When e.g. looking up a socket with O_DIRECTORY, we should return ENOTDIR rather than EACCESS.
2023-09-02Revert "S_dir_lookup: Handle O_DIRECTORY"Samuel Thibault
This reverts commit 8b5b59c704e9edbb0784697ada1df9112fc3e18b. This actually breaks various posix behaviors.
2023-09-02S_dir_lookup: Handle O_DIRECTORYSamuel Thibault
When e.g. looking up a socket with O_DIRECTORY, we should return ENOTDIR rather than EACCESS.
2023-08-12file-syncfs: Avoid deadlockSamuel Thibault
This is a four-player problem (here for diskfs): - One runs sync, which calls diskfs_S_file_syncfs, which triggers fsys_syncfs on all active translators, while keeping the translator_ihash_lock lock. - One of the active translators is hung, for some reason - Another ext2fs thread is trying to call fshelp_set_active_translator from dir_lookup. It is stuck on trying to acquire translator_ihash_lock, and it holds the np. - The ext2fs thread running diskfs_sync_everything tries to lock that np, while holding the nodecache_lock. In the end everything is locked. While diskfs_S_file_syncfs can as well just atomically get the list of active translators, and then call fsys_syncfs without keeping translator_ihash_lock held.
2023-08-08Homogeneize [gs]et_translator and get_dire[nc]ts into mach_msg_type_number_tSamuel Thibault
This makes netfs_[gs]et_translator use mach_msg_type_number_t like the RPC and diskfs. This also makes the fshelp_fetch_root_callback1_t for fshelp_fetch_root use mach_msg_type_number_t. This also makes procfs_get_translator and the get_translator proc method use mach_msg_type_number_t. This makes diskfs_get_directs use mach_msg_type_number_t like the dir_readdir RPC Also get rid of u_int. This notably fixes _diskfs_translator_callback1_fn's bogus cast of size_t *argz_len into (u_int *).
2023-07-03libdiskfs: Don't warn if requesting shutdown notification fails with EPERMSergey Bugaev
The code already ignores proc_mark_important failing with EPERM; do the same for opening /servers/startup and startup_request_notification. All of these calls will fail for unprivileged mounts. Also plug a port leak: we want to deallocate the "init" port whether the RPC succeeds or not. Message-Id: <20230625231137.403096-1-bugaevc@gmail.com>
2023-05-10libdiskfs: Port to x86_64Sergey Bugaev
Message-Id: <20230508213136.608575-9-bugaevc@gmail.com>
2023-05-02Use uintptr_t for message payloads.Flavio Cruz
A follow up to 92fad38a043b75ed6b435b3efa574ede91dbe9ee in gnumach. Message-Id: <ZFCNasf9bJ9qj+CG@jupiter.tail36e24.ts.net>
2023-04-08Further modernize Hurd code by enforcing strict prototypes and no implicit ↵Flavio Cruz
function declarations. Most of the changes land in one of these buckets: * Removed unused declarations. * Used (void) to represent no parameters instead of () which means an undeterminate number of parameters. * Included missing header files whenever necessary (stdlib.h, sys/mman.h, etc) * Typedefed function pointers to be able to fully declare the parameter types. * Added declarations of library functions that are used elsewhere (example is libps/ps.h). * Made functions static whenever they are only used in that file. * Forwarded declarations of some methods that were made static. Message-Id: <ZDD1o7/tVYeZew+G@jupiter.tail36e24.ts.net>
2023-04-07Use default pager MiG stubs from Hurd instead of gnumachFlavio Cruz
Hurd code relies on gnumach default_pager.defs headers when making calls using the default pager RPC. Those stubs were checked in back in the 90s and are essentially unused because gnumach does not implement or use that interface. Instead use the Hurd interface directly. This is safe since the Hurd stubs are a super set of the gnumach stubs. Later, we won't need to install the gnumach stubs anymore through glibc. Message-Id: <ZC5WqPKfCCiE8D29@jupiter.tail36e24.ts.net>
2023-04-03Modernize code by removing use of old style definitions.Flavio Cruz
Also add -Werror=old-style-definition to enforce new code. Message-Id: <ZBZ+8xf7GHy2RT/h@jupiter.tail36e24.ts.net>
2023-01-02fsys_get_children: Fix double-free on errorSamuel Thibault
2023-01-02fsys_get_children: Fix comparing stringsSamuel Thibault
2023-01-02fsys_get_children: Fix memleak on errorSamuel Thibault
2023-01-01Fix accessing cred before checking it is non-NULLSamuel Thibault
2023-01-01libdiskfs: white-list fall-through in switchSamuel Thibault
2023-01-01make_peropen: Fix memory leaks on errorSamuel Thibault
2023-01-01fsys_get_children: Fix double-free on errorSamuel Thibault
2022-12-06Fix *printf specifier for user space mach ports.Flavio Cruz
mach_port_t are mach_port_name_t and thus require %u instead of %lu. Message-Id: <Y42RELMbulK4xaKM@reue>
2022-08-30libdiskfs: Add missing includeSamuel Thibault
2022-08-30libdiskfs: Avoid crashing when stdout/err shuts downSamuel Thibault
stdout/err could shut down for whatever reason (killed the term on /dev/console or whatever). We should not crash just because we lost our ability to print output.
2022-08-29Fix types of read write and readables methodsEtienne Brateau
Message-Id: <20220829193617.13481-1-etienne.brateau@gmail.com>
2022-08-23file_exec: Homogeneize adding the gratuitous send rightSamuel Thibault
2022-08-10libnetfs, libtrivs: Shield S_file_exec_paths () from cancellationSergey Bugaev
Here's the sequence of events that leads to a bug: * A task calls file_exec_paths () on itself, holding the only send right to the protid, passing EXEC_NEWTASK (or EXEC_SECURE, which implies it). * S_file_exec_paths () calls exec_exec_paths () * The exec server sets up a new task and calls proc_reassign () or proc_reauthenticate_reassign (). * The proc server destroys the old task, and the only send right to the protid with it. * The translator gets a no-senders notification, which results in a ports_interrupt_rpcs () call on the S_file_exec_paths (). * This propagates to the exec server (and potentially proc and auth servers). * The exec gets canceled, and the new task gets killed. In my opinion, the party that seems most guilty is the translator canceling exec upon receiving a no-senders notification for the protid. Normally, a no-senders notification means that the caller is no longer interested in the RPC, but this is not true in case of exec. To work around this, create an additional send right to the protid.
2022-08-10libdiskfs, libnetfs: Disable broken codeSergey Bugaev
This logic is obviously broken, let's disable it for now.
2022-08-10diskfs: Use libports notificationsSergey Bugaev
Namely, ports_request_dead_name_notification () where we can, and the libports notify port when we have to pass it to libfshelp.
2022-08-10Do not cache the R/O proxySamuel Thibault
We cannot properly detect when to release the ro_proxy, so let's just not cache it.
2022-01-23typoSamuel Thibault
2022-01-20libdiskfs: improve asserts and remove a sign compare warningEtienne Brateau
Message-Id: <20220119192945.36654-4-etienne.brateau@gmail.com>
2022-01-17Fix const warningsSamuel Thibault
Now that the RPCs have const, this forces us cleaning our const-meant functions.
2022-01-16Make RPC input array parameters constSamuel Thibault
This follows mig's cf4bcc3f1435 ("Also add const qualifiers on server side")
2022-01-01Fix build warningsSamuel Thibault
No actual behavior change.
2021-08-11libdiskfs: Flush node to disk before removing it from the cacheSamuel Thibault
libdiskfs' dosync goes through the cache to flush nodes to the disk. We thus have to flush a node to the disk before removing it from the cache in diskfs_try_dropping_softrefs.
2021-08-11bootstrap: Fix passing proc server from FS to rumpdiskSamuel Thibault
libdiskfs was passing its own proc port, thus confusing the fsys_init call in rumpdisk.
2021-04-11Call _hurd_libc_proc_init when availableSamuel Thibault
glibc 2.33 separated out _hurd_libc_proc_init from _hurd_init, so we have to additionally call it. * configure.ac (_hurd_libc_proc_init): Detect function. * libdiskfs/boot-start.c (diskfs_S_fsys_init): Call _hurd_libc_proc_init. * libmachdev/trivfs_server.c (trivfs_S_fsys_init): Call _hurd_libc_proc_init.
2020-11-27libdiskfs: do not reuse pathbufSamuel Thibault
When deadling with multiple levels of symlinks, we really need double buffering between the current path and the symlink target, and thus cannot reuse pathbuf. * libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): Always use alloca for pathbuf.
2020-10-10libdiskfs: enable relatime by defaultSamuel Thibault
Like Linux does, to avoid writing inodes when just reading files already in the cache. * libdiskfs/init-init.c (_diskfs_relatime): Set to 1. * libdiskfs/opts-std-runtime.c (set_opts): Always _diskfs_relatime from h->relatime.
2020-10-03libdiskfs: Make relatime also update atime when equal to mtime/ctimeSamuel Thibault
Some tests (such as glibc's tst-atime) require it for instance. * libdiskfs/node-times.c (atime_should_update): Also return 1 when atime is equal to mtime or ctime.
2020-09-30libdiskfs: Add relatime supportRyan Jeffrey
* doc/hurd.texi (diskfs_set_node_atime): Document relatime behavior. * libdiskfs/diskfs.h (diskfs_set_node_atime): Likewise. * libdiskfs/init-init.c (_diskfs_relatime): Add variable. * libdiskfs/file-statfs.c (ST_RELATIME): Define if not defined already. (diskfs_S_file_statfs): Report ST_RELATIME when _diskfs_relatime is set. * libdiskfs/node-times.c (atime_should_update): New function. (diskfs_set_node_atime): Document relatime behavior. Call atime_should_update instead of reading _diskfs_noatime. * libdiskfs/opts-common.c (diskfs_common_options): Add --strictatime and -R/--relatime options. * libdiskfs/opts-std-runtime.c (struct parse_hook): Add relatime field. (set_opts): Set _diskfs_relatime from relatime field. (parse_opt): Parse -R option. * libdiskfs/opts-std-startup.c (parse_startup_opt): Parse -R option. * libdiskfs/priv.h (_diskfs_relatime): Declare variable. (atime_should_update): Declare function. * libdiskfs/opts-append-std.c (diskfs_append_std_options): Add reporting --relatime option. * libdiskfs/conch-fetch.c (iohelp_fetch_shared_data): Call atime_should_update instead of reading _diskfs_noatime. * libdiskfs/rdwr-internal.c (_diskfs_rdwr_internal): Likewise.
2020-07-31diskfs: Add RPC for fsys_init to bootstrap if presentDamien Zammit
Message-Id: <20200728100837.224336-1-damien@zamaudio.com>
2020-07-31diskfs: Don't deallocate if dotdot is null in fsys-getroot.cDamien Zammit
Message-Id: <20200728100837.224336-2-damien@zamaudio.com>
2020-07-28libdiskfs: Refactor fsys_startup invokation for bootstrappingDamien Zammit
When we will have a rump translator before the root filesystem translator, we will want to give to the former a control port on the latter. Message-Id: <20200726073721.202405-1-damien@zamaudio.com>
2020-07-25Fix references to startup in commentsSamuel Thibault
2020-06-01libdiskfs: Add missing node lock around fshelp_rlock_drop_peropen callSamuel Thibault
fshelp_rlock_drop_peropen actually needs the node to be locked for proper waiting atomicity.
2020-06-01libdiskfs: Drop spurious mutex acquisitionSamuel Thibault
diskfs_make_peropen does not need node to be locked. Worse, it could try to lock it. * libdiskfs/file-reparent.c (diskfs_S_file_reparent): Do not lock node around diskfs_make_peropen.
2020-05-28libdiskfs,libnetfs: add missing io_pathconf casesSamuel Thibault
* libdiskfs/io-pathconf.c (diskfs_S_io_pathconf): For _PC_REC_MAX_XFER_SIZE, _PC_REC_INCR_XFER_SIZE, _PC_SYMLINK_MAX, return undefined. For _PC_2_SYMLINKS, return 1. For _PC_REC_MIN_XFER_SIZE, _PC_REC_XFER_ALIGN, _PC_ALLOC_SIZE_MIN, return page size. * libnetfs/io-pathconf.c (netfs_S_io_pathconf): Likewise.
2020-03-31Fix build with -fno-commonSamuel Thibault
which will be the default in gcc-10. * acpi/acpifs.h (fs, acpifs_maptime): Add extern qualifier. * boot/private.h (verbose): Likewise. * eth-multiplexer/netfs_impl.h (multiplexer_maptime): Likewise. * eth-multiplexer/vdev.h (port_bucket, vdev_portclass): Likewise. * exec/priv.h (port_bucket, execboot_portclass): Likewise. * ext2fs/ext2fs.h (sblock, sblock_dirty, block_size, log2_block_size, log2_dev_blocks_per_fs_block, log2_stat_blocks_per_fs_block, zeroblock, frag_size, frags_per_block, inodes_per_block, itb_per_group, db_per_group, desc_per_block, addr_per_block, groups_count, node_to_page_lock, generation_lock, next_generation, group_desc_image, global_pokel, modified_global_blocks, use_xattr_translator_records): Likewise. * hostmux/hostmux.h (hostmux_maptime): Likewise. * isofs/isofs.h (host_name, mounted_on, disk_image, disk_image_len, logical_block_size, sblock): Likewise. * libdiskfs/diskfs.h (diskfs_shortcut_symlink, diskfs_shortcut_chrdev, diskfs_shortcut_blkdev, diskfs_shortcut_fifo, diskfs_shortcut_ifsock, diskfs_create_symlink_hook, diskfs_read_symlink_hook): Likewise. * libnetfs/callbacks.h (_netfs_translator_callback1, _netfs_translator_callback2): Likewise. * libnetfs/priv.h (netfs_mtime): Likewise. * libpager/priv.h (_pager_class): Likewise. * libtrivfs/trivfs.h (trivfs_check_access_hook, trivfs_check_open_hook, trivfs_open_hook, trivfs_protid_create_hook, trivfs_peropen_create_hook, trivfs_protid_destroy_hook, trivfs_peropen_destroy_hook, trivfs_getroot_hook): Likewise. * lwip/lwip-hurd.h (lwip_bucket, socketport_class, addrport_class, shutdown_notify_class, lwip_protid_portclasses, lwip_cntl_portclasses, lwip_bootstrap_portclass, fsys_identity, lwipcntl, lwip_owner, lwip_group): Likewise. * lwip/port/include/netif/hurdtunif.h (tunnel_cntlclass, tunnel_class): Likewise. * nfs/nfs.h (main_udp_socket, hostname, mapped_time): Likewise. * nfsd/nfsd.h (mapped_time, authserver): Likewise. * pci-arbiter/pcifs.h (fs, pcifs_maptime): Likewise. * pci-arbiter/startup.h (pci_shutdown_notify_class, arrange_shutdown_notification): Likewise. * pfinet/pfinet.h (pfinet_bucket, addrport_class, socketport_class, fsys_identity, pfinetctl, pfinet_owner, pfinet_group): Likewise. * pflocal/sserver.h (sock_port_bucket): Likewise. * proc/proc.h (authserver, self_proc, init_proc, startup_proc, proc_bucket, proc_class, generic_port_class, exc_class, generic_port, kernel_proc, global_lock): Likewise. * term/term.h (termstate, termflags, global_lock, carrier_alert, select_alert, pty_select_alert, term_bucket, tty_cntl_class, tty_class, cttyid_class, pty_class, pty_cntl_class, termctl, ptyctl, inputq, rawq, outputq, remote_input_mode, external_processing, term_owner, term_group, term_mode, bottom): Likewise. * usermux/usermux.h (usermux_maptime): Likewise. * utils/msgids.h (msgid_argp): Likewise. * libdiskfs/priv.h (_diskfs_mtime): Remove definition. * lwip/options.h (lwip_argp): Add prototype. * mach-defpager/priv.h (partitions): Name structure. (all_partitions): Add extern qualifier. * acpi/main.c (acpifs_maptime, fs): New variables. * exec/main.c (port_bucket, execboot_portclass): Likewise. * ext2fs/ext2fs.c (sblock, sblock_dirty, block_size, log2_block_size, log2_dev_blocks_per_fs_block, log2_stat_blocks_per_fs_block, frag_size, frags_per_block, inodes_per_block, itb_per_group, db_per_group, desc_per_block, addr_per_block, groups_count, next_generation, group_desc_image, global_pokel, use_xattr_translator_records): Likewise. * isofs/main.c (host_name, mounted_on, logical_block_size, sblock): Likewise. * libpager/pager-create.c (_pager_class): Likewise. * lwip/port/netif/hurdtunif.c (tunnel_cntlclass, tunnel_class): Likewise. * mach-defpager/default_pager.c (all_partitions): Likewise. * nfs/main.c (main_udp_socket, hostname, mapped_time): Likewise. * nfsd/main.c (mapped_time, authserver): Likewise. * pci-arbiter/main.c (fs, pcifs_maptime): Likewise. * pci-arbiter/startup.c (*pci_shutdown_notify_class): Likewise. * pfinet/main.c (pfinetctl, pfinet_owner, pfinet_group, pfinet_bucket, addrport_class, socketport_class, fsys_identity): Likewise. * proc/main.c (authserver, self_proc, init_proc, startup_proc, proc_bucket, proc_class, generic_port_class, exc_class, generic_port, kernel_proc, global_lock): Likewise. * term/main.c (termstate, termflags, global_lock, carrier_alert, select_alert, pty_select_alert, term_bucket, tty_cntl_class, tty_class, cttyid_class, pty_class, pty_cntl_class, termctl, ptyctl, outputq, remote_input_mode, external_processing, term_owner, term_group, term_mode, bottom): Likewise. * usermux/usermux.c (usermux_mapped_time): Rename to usermux_maptime. * lwip/main.c: Include "options.h". (lwip_argp, netif_list): Remove declarations. (lwip_bucket, socketport_class, addrport_class, shutdown_notify_class, lwip_cntl_portclasses, lwip_bootstrap_portclass, lwip_owner, lwip_group, fsys_identity, lwipcntl): New variables. * eth-multiplexer/multiplexer.c (multiplexer_maptime): Add variable. * hostmux/hostmux.c (hostmux_mapped_time): Rename variable to hostmux_maptime * libdiskfs/extra-version.c: Rename file to... * libdiskfs/priv.c: ... new file. (diskfs_shortcut_symlink, diskfs_shortcut_chrdev, diskfs_shortcut_blkdev, diskfs_shortcut_fifo, diskfs_shortcut_ifsock, diskfs_create_symlink_hook, diskfs_read_symlink_hook): Add weak variables. * libdiskfs/Makefile (OTHERSRCS): Replace extra-version.c with priv.c. * libtrivfs/priv.c: New file. * libtrivfs/Makefile (OTHERSRCS): Add priv.c * libcons/extra-version.c: Rename file to... * libcons/priv.c: ... new file. * libcons/Makefile (SRCS): Replace extra-version.c with priv.c. Fix build with #
2019-11-10libfshelp: Fix memleakSamuel Thibault
* libfshelp/fshelp.h (fshelp_rlock_po_fini): New inline function. * libdiskfs/peropen-rele.c (diskfs_release_peropen): Call fshelp_rlock_po_fini. * libnetfs/release-peropen.c (netfs_release_peropen): Likewise.
2019-10-30libdiskfs: Support for file record lockingNeal H Walfield
2019-03-04 Svante Signell <svante.signell@gmail.com> * file-lock.c: Make flock work regardless of the mode in which the file was opened. 2019-02-12 Svante Signell <svante.signell@gmail.com> * file-lock.c: Comment out "Make flock work without R or W mode" 2019-02-01 Svante Signell <svante.signell@gmail.com> * Update copyright years. * file-record-lock.c(diskfs_S_file_record_lock): Don't set rendezvous to MACH_PORT_NULL. 2018-12-07 Svante Signell <svante.signell@gmail.com> * Update copyright years. * dir-lookup.c(diskfs_S_dir_lookup): Call fshelp_rlock_tweak() with new last argument rendezvous = MACH_PORT_NULL. * file-lock.c(diskfs_S_file_lock): Likewise. * file-record-lock.c(diskfs_S_file_record_lock): Likewise. (diskfs_S_file_record_lock): Add new argument mach_port_t rendezvous. 2017-01-05 Svante Signell <svante.signell@gmail.com> * Update copyright years and headers. 2016-05-23 Svante Signell <svante.signell@gmail.com> * file-lock-stat.c: Port from cthreads to libpthread. * file-lock.c: Likewise. * file-record-lock: Likewise. 2001-04-11 Neal H Walfield <neal@cs.uml.edu> * Makefile (FSSRCS): Add file-record-lock.c. * diskfs.h (struct peropen): Change the type of lock_status from an int to a struct rlock_peropen. (struct node): Change the type of userbox from a struct lock_box to a struct rlock_box. * dir-lookup.c (diskfs_S_dir_lookup): Use fshelp_rlock_tweak as fshelp_acquire_lock is now depreciated. * file-lock-stat.c (diskfs_S_file_lock_stat): Total rewrite around the new record locking functions. * file-lock.c (diskfs_S_file_lock): Total rewrite around the new record locking functions. * file-record-lock.c: New file. Implement diskfs_S_file_record_lock. * node-make.c (diskfs_make_node): Initialize userbox with fshelp_rlock_init. * peropen-make.c (diskfs_make_peropen): Initialize lock_status using fshelp_rlock_po_init. * peropen-rele.c (diskfs_release_peropen): Release lock_status using fshelp_rlock_drop_peropen.