summaryrefslogtreecommitdiff
path: root/trans/mtab.c
AgeCommit message (Collapse)Author
2019-09-01Use the data_t type defined in hurd_types.h.Flavio Cruz
* boot/boot.c: Replace char* with data_t. * console-client/trans.c: Likewise. * exec/exec.c: Likewise. * ext2fs/storeinfo.c: Likewise. * fatfs/inode.c: Likewise. * fatfs/main.c: Likewise. * isofs/inode.c: Likewise. * libdiskfs/boot-start.c: Likewise. * libdiskfs/dir-readdir.c: Likewise. * libdiskfs/file-exec.c: Likewise. * libdiskfs/file-get-fs-opts.c: Likewise. * libdiskfs/file-get-trans.c: Likewise. * libdiskfs/file-getfh.c: Likewise. * libdiskfs/file-set-trans.c: Likewise. * libdiskfs/fsys-forward.c: Likewise. * libdiskfs/fsys-getfile.c: Likewise. * libdiskfs/fsys-options.c: Likewise. * libdiskfs/io-read.c: Likewise. * libdiskfs/io-write.c: Likewise. * libnetfs/dir-readdir.c: Likewise. * libnetfs/file-exec.c: Likewise. * libnetfs/file-get-fs-options.c: Likewise. * libnetfs/file-get-storage-info.c: Likewise. * libnetfs/file-get-translator.c: Likewise. * libnetfs/file-set-translator.c: Likewise. * libnetfs/fsstubs.c: Likewise. * libnetfs/fsys-get-options.c: Likewise. * libnetfs/fsys-set-options.c: Likewise. * libnetfs/fsysstubs.c: Likewise. * libnetfs/io-read.c: Likewise. * libnetfs/io-write.c: Likewise. * libtrivfs/dir-readdir.c: Likewise. * libtrivfs/file-get-fs-options.c: Likewise. * libtrivfs/file-get-storage-info.c: Likewise. * libtrivfs/file-get-trans.c: Likewise. * libtrivfs/file-getfh.c: Likewise. * libtrivfs/file-set-trans.c: Likewise. * libtrivfs/fsys-forward.c: Likewise. * libtrivfs/fsys-get-options.c: Likewise. * libtrivfs/fsys-set-options.c: Likewise. * libtrivfs/fsys-stubs.c: Likewise. * libtrivfs/io-read.c: Likewise. * libtrivfs/io-write.c: Likewise. * pfinet/io-ops.c: Likewise. * pfinet/pfinet-ops.c: Likewise. * pfinet/socket-ops.c: Likewise. * pfinet/tunnel.c: Likewise. * pflocal/io.c: Likewise. * pflocal/pf.c: Likewise. * pflocal/socket.c: Likewise. * proc/info.c: Likewise. * startup/startup.c: Likewise. * storeio/io.c: Likewise. * term/users.c: Likewise. * tmpfs/node.c: Likewise. * trans/crash.c: Likewise. * trans/fakeroot.c: Likewise. * trans/fifo.c: Likewise. * trans/firmlink.c: Likewise. * trans/hello-mt.c: Likewise. * trans/hello.c: Likewise. * trans/mtab.c: Likewise. * trans/new-fifo.c: Likewise. * trans/null.c: Likewise. * trans/proxy-defpager.c: Likewise. * trans/streamio.c: Likewise.
2017-09-12Traverse translator hierarchies using the fsys protocol.Justus Winter
Previously, we used the fs protocol to traverse the translator hierarchies. This, however, is conceptually flawed, because translators are bound to nodes, and a node can have zero or more links in the file system. Therefore, the previous method of returning a list of paths to the client and expecting them to be able to follow these to reach the child translators was always unreliable. Fix this by using the fsys protocol to traverse the hierarchy, and returning the control ports of all children. This is more robust, and also conceptually cleaner, because the fsys protocol is about translator linkage, hence this is the point to implement traversal. Also move the get source routine over. A per-node source really does not fit the reality of most translators, while a per-translator source makes sense in many cases. * hurd/fs.defs (file_get_children): Drop routine. (file_get_source): Likewise. * hurd/fsys.defs (fsys_get_children): New routine. (fsys_get_source): Likewise. * libdiskfs/Makefile (FSYSSRCS): Remove files, add files. * libdiskfs/file-get-children.c: Remove file. * libdiskfs/fsys-get-children.c: New file. * libdiskfs/file-get-source.c: Remove file. * libdiskfs/fsys-get-source.c: New file. * libfshelp/fshelp.h (fshelp_filter): Remove type. (fshelp_get_active_translators): Remove filter and prefix argument, return list of control ports. * libfshelp/translator-list.c (fshelp_get_active_translators): Likewise. * libnetfs/Makefile (FSSRCS): Move 'get-source.c' too OTHERSRCS. (FSYSSRCS): Remove files, add files. * libnetfs/file-get-children.c: Remove file. * libnetfs/fsys-get-children.c: New file. * libnetfs/file-get-source.c: Remove file. * libnetfs/fsys-get-source.c: New file. * libtrivfs/Makefile: Move 'get-source.c' too OTHERSRCS. (FSYSSRCS): Remove files, add files. * libtrivfs/file-get-children.c: Remove file. * libtrivfs/fsys-get-children.c: New file. * libtrivfs/file-get-source.c: Remove file. * libtrivfs/fsys-get-source.c: Add file. * trans/Makefile (mtab): Build client stubs until the libc has caught on. * trans/mtab.c (target_control): New variable. (insecure): Drop variable. (all_translators): Likewise. (MAX_DEPTH): New macro. (max_depth): New variable. (options): Remove '--insecure' and '--all-translators', add '--depth'. (parse_opt): Adapt accordingly. (trivsfs_append_args): Likewise. (main): Get the control port of the target translator, then drop privileges. (is_filesystem_translator): Remove function. (mtab_mark_as_seen): Simplify. Just check if the control port is known. (mtab_populate): Limit depth of recursion, adapt to traversing over the control ports, simplify. (open_hook): Remove scary comment, it is not applicable anymore because we no longer dir_lookup child translators.
2017-09-01trans/mtab: Fix warnings.Justus Winter
* trans/mtab.c (get_credentials): Fix error handling. (mtab_populate): Fix type. (trivfs_S_io_seek): Avoid implicit fallthrough warnings.
2016-06-04Do not make io_select return errors on unsupported READ/WRITE modeSamuel Thibault
The descriptor is valid, it is just the mode which is not available. * console-client/kbd-repeat.c (repeater_select): Drop SELECT_URG flag from `type'. Return 0 instead of EINVAL if `type' contains SELECT_WRITE. * console-client/pc-mouse (repeater_select): Likewise. * trans/mtab.c (trivfs_S_io_select): Return 0 instead of EBADF when the openmodes do not match the requested modes in `type'. * trans/new-fifo.c (io_select_common): Likewise. * trans/fifo.c (io_select_common): Likewise. * trans/null.c (trivfs_S_io_select): Likewise. * trans/streamio.c (io_select_common): Likewise.
2016-03-15Show firmlink mounts to mount pointsSamuel Thibault
* trans/mtab.c (mtab_populate): Always open the underlying node, and pass it to mtab_mark_as_seen instead of the translated node.
2015-12-29fix compiler warnings in hurd/transFlavio Cruz
trans: Fix compiler warnings. * trans/mtab.c (mtab_mark_as_seen): Cast idport to hurd_ihash_value_t. * trans/streamio.c (dev_open): Cast name to char *.
2014-11-21trans/mtab: avoid firmlink loopsJustus Winter
* trans/mtab.c (struct mtab): Add a hash table to keep track of seen ports. (mtab_mark_as_seen): New function that records the identity port of a given node in the hash table and reports whether it has been there before. (mtab_populate): Use the new function to avoid running in circles. (main, open_hook): Initialize hash table. (close_hook): Free ports and destroy hash table.
2014-08-31trans/mtab: use setnullauth to drop privilegesJustus Winter
* trans/mtab.c (main): Use setnullauth to drop privileges.
2014-05-26trans/mtab: fix initializationJustus Winter
* trans/mtab.c (main): Fix initialization of mtab in one-shot mode.
2014-04-15Include the MIG-generated server header filesJustus Winter
This enables the compiler to check that the server function declarations match MIGs expectations. Fix a few oddities along the way. * console-client/trans.c: Include MIG-generated server header file(s). * console/console.c: Likewise. Also, fix declarations. * console/mutations.h (TIOCTL_IMPORTS): Just use libnetfs/priv.h. * console/priv.h: Delete now unused file. * ext2fs/storeinfo.c: Include MIG-generated server header file(s). * fatfs/inode.c: Likewise. * fatfs/main.c: Likewise. Also, fix declaration. * isofs/inode.c: Likewise. * libdiskfs/boot-start.c: Likewise. * libdiskfs/file-chg.c: Include the correct MIG-generated server header file. * libdiskfs/file-chmod.c: Include MIG-generated server header file(s). * libdiskfs/file-get-fs-opts.c: Likewise. * libdiskfs/init-startup.c: Likewise. * libnetfs/file-get-children.c: Likewise. * libnetfs/file-getcontrol.c: Include the correct MIG-generated server header file. * libnetfs/file-set-translator.c: Include MIG-generated server header file(s). * libnetfs/fsstubs.c: Likewise. * libtrivfs/file-access.c: Likewise. * libtrivfs/file-chauthor.c: Likewise. * libtrivfs/file-chflags.c: Likewise. * libtrivfs/file-chg.c: Likewise. * libtrivfs/file-chmod.c: Likewise. * libtrivfs/file-chown.c: Likewise. * libtrivfs/file-exec.c: Likewise. * libtrivfs/file-get-children.c: Likewise. * libtrivfs/file-get-fs-options.c: Likewise. * libtrivfs/file-get-source.c: Likewise. * libtrivfs/file-get-storage-info.c: Likewise. * libtrivfs/file-get-trans.c: Likewise. * libtrivfs/file-get-transcntl.c: Likewise. * libtrivfs/file-getcontrol.c: Likewise. * libtrivfs/file-getfh.c: Likewise. * libtrivfs/file-getlinknode.c: Likewise. * libtrivfs/file-lock.c: Likewise. * libtrivfs/file-reparent.c: Likewise. * libtrivfs/file-set-size.c: Likewise. * libtrivfs/file-set-trans.c: Likewise. * libtrivfs/file-statfs.c: Likewise. * libtrivfs/file-sync.c: Likewise. * libtrivfs/file-syncfs.c: Likewise. * libtrivfs/file-utimes.c: Likewise. * libtrivfs/fsys-forward.c: Likewise. * libtrivfs/fsys-get-options.c: Likewise. * libtrivfs/fsys-getroot.c: Likewise. * libtrivfs/fsys-goaway.c: Likewise. * libtrivfs/fsys-set-options.c: Likewise. * libtrivfs/fsys-stubs.c: Likewise. * libtrivfs/fsys-syncfs.c: Likewise. * libtrivfs/io-async-icky.c: Likewise. * libtrivfs/io-async.c: Likewise. * libtrivfs/io-duplicate.c: Likewise. * libtrivfs/io-identity.c: Likewise. * libtrivfs/io-map.c: Likewise. * libtrivfs/io-modes-get.c: Likewise. * libtrivfs/io-modes-off.c: Likewise. * libtrivfs/io-modes-on.c: Likewise. * libtrivfs/io-modes-set.c: Likewise. * libtrivfs/io-owner-get.c: Likewise. * libtrivfs/io-owner-mod.c: Likewise. * libtrivfs/io-pathconf.c: Likewise. * libtrivfs/io-read.c: Likewise. * libtrivfs/io-readable.c: Likewise. * libtrivfs/io-reauthenticate.c: Likewise. * libtrivfs/io-restrict-auth.c: Likewise. * libtrivfs/io-revoke.c: Likewise. * libtrivfs/io-seek.c: Likewise. * libtrivfs/io-select.c: Likewise. * libtrivfs/io-stat.c: Likewise. * libtrivfs/io-stubs.c: Likewise. * libtrivfs/io-version.c: Likewise. * libtrivfs/io-write.c: Likewise. * pfinet/tunnel.c: Likewise. * storeio/io.c: Likewise. * storeio/storeio.c: Likewise. * term/users.c: Likewise. * tmpfs/node.c: Likewise. * trans/fakeroot.c: Likewise. Also, include all server headers that provide the X_server_routine functions... (netfs_demuxer): ... that were previously declared here. * trans/fifo.c: Include MIG-generated server header file(s). * trans/firmlink.c: Likewise. * trans/hello-mt.c: Likewise. * trans/hello.c: Likewise. * trans/magic.c: Likewise. * trans/mtab.c: Likewise. * trans/new-fifo.c: Likewise. * trans/null.c: Likewise. * trans/proxy-defpager.c: Likewise. * trans/streamio.c: Likewise. * libdiskfs/fsmutations.h: Qualify the import with the libraries path. Without this change, out-of-tree builds would no longer work. * libnetfs/mutations.h: Likewise. * libtrivfs/mig-mutate.h: Likewise.
2014-02-25trans/mtab: do not map unknown source strings to "none"Justus Winter
Previously, map_device_to_path mapped unknown device strings to "none". Return a copy of the original source string instead so that e.g. nfs mount point points are properly handled. * trans/mtab.c (map_device_to_path): Do not map unknown source strings to "none".
2014-02-25trans/mtab: ignore translators that do not implement file_get_sourceJustus Winter
Previously, the mtab translator would guess the source of a filesystem translator from its last argument. This made all kinds of non-filesystem translators appear in /proc/mounts, causing severe problems due to umount --all removing vital passive translator records. Fix this by ignoring all translators that do not explicitly implement file_get_source. * trans/mtab.c (mtab_populate): Ignore translators that do not implement file_get_source.
2014-02-25hurd: fix the get-children and get-source proceduresJustus Winter
* hurd/fs.defs: Add file_get_children and file_get_source. * hurd/fsys.defs: Remove fsys_get_children and fsys_get_source. * libdiskfs/fsys-get-children.c: Rename and adapt accordingly. * libdiskfs/fsys-get-source.c: Likewise. * libnetfs/fsys-get-children.c: Likewise. * libnetfs/fsys-get-source.c: Likewise. * libtrivfs/fsys-get-children.c: Likewise. * libtrivfs/fsys-get-source.c: Likewise. * libdiskfs/diskfs.h: Adapt prototype and comment. * libnetfs/netfs.h: Likewise. * libtrivfs/trivfs.h: Likewise. * libdiskfs/get-source.c: Adapt default implementation, provide diskfs_disk_name by default. * libnetfs/netfs.h: Adapt default implementation. * libtrivfs/get-source.c: Likewise. * libdiskfs/Makefile: Adapt accordingly. * libnetfs/Makefile: Likewise. * libtrivfs/Makefile: Likewise. * trans/symlink.c: Likewise. * trans/mtab.c: Likewise.
2014-01-12trans/mtab: do not include non-filesystem translators by defaultJustus Winter
Traditionally, /proc/mounts includes only filesystem mount points. Previously though, the mtab translator included any kind of translator, like all /hurd/storeio translators. This causes problems with umount --all as this would remove the passive translator records from nodes in /dev. Fix this by only listing filesystem-like translators by default. Filesystem-like translators are identified by their response to dir_readdir messages sent to their root node. * trans/mtab.c (all_translators): New variable. (options): Add flag to preserve the old behavior. (parse_opt): Handle the new flag. (is_filesystem_translator): New function. (mtab_populate): Skip non-filesystem translators by default.
2014-01-12trans/mtab: make the translator multithreadedJustus Winter
* trans/mtab.c (main): Use ports_manage_port_operations_multithread.
2014-01-12trans/mtab: properly lock mtab objectsJustus Winter
* trans/mtab.c (struct mtab): Add lock. (open_hook): Initialize lock. (close_hook): Destroy lock. (trivfs_S_io_read): Lock mtab object, adjust error handling accordingly. (trivfs_S_io_seek): Likewise. (trivfs_S_io_readable): Likewise.
2014-01-12trans/mtab: remove the loop detection logicJustus Winter
Previously the mtab detector tried to detect whether it talks to itself by comparing the control port of the translator it currently visits with its own. This was done to prevent deadlocks. However, this did not detect non-trivial loops, i.e. two mtab translators would still dead-lock each other. Now that it is safe to actually file_name_lookup the root node of a mtab translator without triggering the generation of content, this logic can just be omitted. * trans/mtab.c (mtab_populate): Remove the loop detection logic.
2014-01-12trans/mtab: populate mtab objects on demandJustus Winter
Previously the mtab content was generated in the open hook. Delay this until the data is needed. A follow up patch will take advantage of this to both simplify the logic in mtab_populate and make it more robust at the same time. * trans/mtab.c (open_hook): Do not eagerly populate the mtab. (trivfs_S_io_read): Populate the mtab struct on demand. (trivfs_S_io_seek): Likewise. (trivfs_S_io_readable): Likewise.
2013-10-08trans: rename a global variableJustus Winter
Rename the global variable "path" to "target_path" to make it more unambiguous. * trans/mtab.c: Rename global variable "path".
2013-09-15trans: add mtab translatorJustus Winter
The mtab translator provides an mtab file that is dynamically created on demand. It is populated with information about active translators bound below the given path that is accumulated by traversing the translator tree. It can also be invoked as normal program that prints the requested information to stdout. * trans/mtab.c: New file. * trans/Makefile: Build mtab.