summaryrefslogtreecommitdiff
path: root/sys/src/9/port/sysfile.c
AgeCommit message (Collapse)Author
2022-05-28kernel: add chdev command to devconsJacob Moody
2021-10-23kernel: make growfd(), findfreefd() and newfd2() staticcinap_lenrek
2021-10-23kernel: fix stat bugscinap_lenrek
In a few places, we where using a fixed buffer of sizeof(Dir)+100 size for stat. This is not correct and fails if the name returned in stat is long. This results in being unable to seek to the end of file with a long filename. The kernel should do the same thing as dirfstat() from libc; handling the conversion and buffer allocation and returning a freeable Dir* pointer. For this, a new dirchanstat() function was added. The fstat syscall was not rewriting the name to the last path element; fix it. In addition, gracefully handle the mountfix case, reallocating the buffer to accomidate the required stat length plus size of the new name so dirsetname() does not fail.
2021-10-03kernel: ensure that all accesses to Mhead.mount is done with Mhead.lock acquiredcinap_lenrek
The Mhead structures have two sources of references to them: - from Pgrp.mnthash hash-table - from a channels Chan.umh pointer as returned by namec() for a union directory Unless one holds the Mhead.lock RWLock, the Mhead.mount chain can be mutated by eigther cmount(), cunmount() or closepgrp(). Readers, skipping acquiering the lock where: mountfix(): responsible for rewriting directory entries for union directory reads; was walking the Mhead.mount chain to detect if the passed channel itself appears in the mount list. cmount(): had a check and copy when "new" chan was a union itself and if the MCREATE flag is set and would copy the mount table. All this needs to be done with Mhead read-locked while copying the mount entries. devproc(): in the handler for reading /proc/n/ns file. namec(): while checking if the Chan->umh should be initialized. In addition to this, cmount() is changed to do the mountfree() of the original mount chain when MREPL is done after releasing the locks. Also, some cosmetic changes...
2020-12-13kernel: implement per file descriptor OCEXEC flag, reject ORCLOSE when ↵cinap_lenrek
opening /fd, /srv and /shr The OCEXEC flag used to be maintained per channel, making it shared between all the file desciptors. This has a unexpected side effects with regard to channel passing drivers such as devdup (/fd), devsrv (/srv) and devshr (/shr). For example, opening a /srv file with OCEXEC makes it impossible to be remounted by exportfs as it internally does a exec() to mount and re-export it. There is no way to reset the flag. This change makes the OCEXEC flag per file descriptor, so a open with the OCEXEC flag only affects the fd group of the calling process, and not the channel itself. On rfork(RFFDG), the per file descriptor flags get copied. On dup(), the per file descriptor flags are reset. The second modification is that /fd, /srv and /shr should reject the ORCLOSE flag, as the files that are returned have already been opend.
2017-04-30kernel: fix rewinding in directories with pread() offsetcinap_lenrek
reading directories with pread() offset has to work the same way as read(), otherwise exportfs breaks rewinding in directories.
2016-05-16avoid updating offset in pread; avoid diagnostic about vlong mask (charles ↵cinap_lenrek
forsyth)
2015-08-09kernel: mount flag is int not ulong, reduce size of Mount struct by putting ↵cinap_lenrek
mflag field in what would be wasted as padding
2015-07-28kernel: export mntattach() from devmnt.c avoiding bogus struct passing and ↵cinap_lenrek
special case in namec() we already export mntauth() and mntversion(), so why not stop being sneaky and just export mntattach() so bindmount() and devshr can just call it directly with proper arguments being checked. we can also avoid handling #M attach specially in namec() by having the devmnt's attach function do error(Enoattach).
2015-07-23kernel: make sure fd is in range in fdclose()cinap_lenrek
as the Fgrp can be shared with other processes, we have to recheck the fd index after locking the Fgrp in fdclose() to make sure not to read beyond the bounds of the fd array.
2015-07-23kernel: simplify syspipe()cinap_lenrek
2015-07-22kernel: consistent use of nil for pointer in sysfile.ccinap_lenrek
2014-08-08kernel: use nil for pointers instead of 0, zero channel umc and dirrock in ↵cinap_lenrek
newchan()
2014-05-26kernel: simplify fdclose()cinap_lenrek
2014-05-20add _nsec() syscall 53 for binary compatibility with labs distributioncinap_lenrek
the new syscall is added under the symbol _nsec() for binary compatibility. nsec() is still a library function reading /dev/bintime.
2014-02-02kernel: do not pass user address of fd[2] array to newfd2()cinap_lenrek
access to user memory can pagefault and newfd2() holds fgrp spinlock while writing to it. make temporary copy on the stack in syspipe().
2014-01-20kernel: apply uintptr for ulong when a pointer is storedcinap_lenrek
this change is in preparation for amd64. the systab calling convention was also changed to return uintptr (as segattach returns a pointer) and the arguments are now passed as va_list which handles amd64 arguments properly (all arguments are passed in 64bit quantities on the stack, tho the upper part will not be initialized when the element is smaller than 8 bytes). this is partial. xalloc needs to be converted in the future.
2012-04-27async clunk for cached mounts, fix closeproc explosioncinap_lenrek
2011-08-11eqlock(): use eqlock when interruption is possiblecinap_lenrek
2011-03-30Import sources from 2011-03-30 iso image - libTaru Karttunen
2011-03-30Import sources from 2011-03-30 iso imageTaru Karttunen