afs: introduce afs_alloc_ncr/afs_free_ncr There is duplicated code for initializing a nocache_read_request and also freeing the associated storage in certain cases. Create a set of helper functions that allocates and frees a nocache_read_request and its associated structures. afs_alloc_ncr allocates a nocache_read_request structure and if not UKERNEL, will allocate and initialize the associated uio and iovec structures. afs_free_ncr releases a noncache_read_request structure and the associated uio and iovec structures if not UKERNEL. Update locations that allocate/free nocache_read_request structures to use the new functions. Change-Id: I80c0b4eb036bcb1223b73f4c1de2c12be362de42 Reviewed-on: https://gerrit.openafs.org/14954 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
DARWIN: Declare/include functions before using them Every function should be explicitly declared before it can be called. Since -Wimplicit-function-declaration is usually a warning and not an error, calling undeclared functions does not prevent us from building the code. However, apple-clang 12 makes this an error by default, prohibiting the build of the current version on macOS 11 (Big Sur). To fix this problem, declare functions before calling them. Also, include mach/thread_act.h into afs_call.c so the declaration of thread_terminate() can be found on macOS. Last, given that the third argument of PIOCTL() (if UKERNEL is defined) is a pointer, cast it to 'long'. Doing so, we can avoid another inhibited warning. Notice that this PIOCTL definition is scoped to a single file (src/auth/ktc.c). Change-Id: I6d796c10ea4dd81b13ae5feb9f42608aa445560d Reviewed-on: https://gerrit.openafs.org/14744 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
UKERNEL: Remove flock -> usr_flock redirection In order to replace 'struck flock' with 'struct usr_flock' and 'flock()' with 'usr_flock()', the current version of src/afs/UKERNEL/sysincludes.h defines flock to usr_flock. This can cause problems when trying to use libroken in UKERNEL code, because roken.h redefines flock. To avoid conflicts with libroken (included in a future commit), add a new UKERNEL specific AFS_FLOCK -> usr_flock redirection. Doing so, the flock -> usr_flock redirection can be removed. While here, also remove 'usr_flock()' as it shouldn't be called and is not defined in any header file. Change-Id: Ia71811513ab6655f60d8b63fc18b26be663ab4dc Reviewed-on: https://gerrit.openafs.org/14913 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
afs: Always define our own osi_timeval32_t Since OpenAFS 1.0, osi_GetTime has taken a timeval-like pointer, which contains 32-bit fields (the actual type has been called either osi_timeval_t or osi_timeval32_t over time). For platforms that have a native timeval-like type with 32-bit fields, we just define osi_timeval32_t to that type, and elsewhere we define our own struct to be osi_timeval32_t. For platforms that use the native timeval, we can then define osi_GetTime() to just be, e.g., microtime(). This approach is difficult to maintain, though, because we must keep track of whether 'struct timeval' contains 32-bit fields on each platform, which can depend on many factors. It's easy to make mistakes (the current tree already contains mistakes), and there's not much benefit. To avoid all of this, just always define osi_timeval32_t to be our own struct with afs_int32 fields, and provide definitions for osi_GetTime that convert from the native time struct to our osi_timeval32_t. This does mean that for some platforms we do an unnecessary type conversion, but this is a small price to pay for more straightforward and maintainable code. To be a little more sure that our types are correct, change osi_GetTime to be defined as an inline function instead of a macro. At the same time, do a similar conversion for the KERNEL implementation of the rx clock_GetTime function. Get rid of platform-specific mess, and do a straightforward type conversion between osi_timeval32_t and struct clock in an inline function. Change-Id: I18819acb556a2a7f1b6da6994db9783c48108934 Reviewed-on: https://gerrit.openafs.org/14238 Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
UKERNEL: remove dead code osi_SetTime osi_SetTime has been dead code since the original IBM code import. Remove it from the tree. No functional change is incurred by this commit. Change-Id: I25612a044ad550d798003979afc6845e502ebe3b Reviewed-on: https://gerrit.openafs.org/14191 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
afs: Properly type afs_osi_suser cred arg Currently, afs_osi_suser is declared with a void* argument, even though its only argument is always effectively a afs_ucred_t*. This allows us to call afs_osi_suser with any pointer type without the compiler complaining. Currently, some callers call afs_osi_suser with an incorrectly-typed afs_ucred_t** instead, like so: func(afs_ucred_t **credpp) { afs_ucred_t **acred = *acredpp; /* incorrect assignment */ if (afs_osi_suser(acred)) { /* ... */ } } The actual code in the tree hides this to some degree behind various function calls and layers of indirection (e.g. afs_suser()), but this is effectively what we do. This causes compiler warnings because we are doing incorrect pointer assignments, but the end result works because afs_osi_suser actually uses an afs_ucred_t*. The type confusion makes it very easy to accidentally give the wrong type to afs_osi_suser. This only really matters on SOLARIS, since that is the only platform that actually uses its argument to afs_osi_suser(). To fix all of this, just declare afs_osi_suser as taking an afs_ucred_t*, and fix all of the relevant functions to handle the right type. Change-Id: I1366aedf0f3d7689735a9424c5272233931e3bf2 Reviewed-on: https://gerrit.openafs.org/14085 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
afs: remove dead code afs_osi_SetTime afs_osi_SetTime() has been dead code since -settime support was removed with commit 1d9888be486198868983048eeffabdfef5afa94b 'Remove -settime/RXAFS_GetTime client support'. Remove the dead code. No functional change is incurred by this commit. Change-Id: Ie5559325b4c98d7e0786c75ae6507ab9c2c47376 Reviewed-on: https://gerrit.openafs.org/13393 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: Benjamin Kaduk <kaduk@mit.edu>
Use afs_DestroyReq in afs_PrefetchNoCache() Since commit 76ad941902c650a4a716168d3cbe68f62aef109f we use afs_DestroyReq() instead of osi_Free() directly. Also update the UKERNEL version of the function to afs_CreateReq() properly. FIXES 134533 Change-Id: I4a13f6232dbed12ee00ce219cb5f515529fff58c Reviewed-on: https://gerrit.openafs.org/13060 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Remove kauth headers from afs_usrops.c Since ka_* functions are no longer called from here, we don't need the headers Change-Id: I538c27cf4fe2f16811d1d3056b25054c80ba5b2a Reviewed-on: http://gerrit.openafs.org/9956 Reviewed-by: D Brashear <shadow@your-file-system.com> Tested-by: BuildBot <buildbot@rampaginggeek.com>
libafs: fix some nits around the symlink VOP Commit 3f4c1099b7b (gerrit 10474) introduced a few issues, addressed here. vpp is idiomatically of type 'struct vnode *', not 'struct vcache *'; use pvc as the name of the parent vcache pointer instead. Fix whitespace. Change-Id: Ic5d98a43446861bb571fe5a260e7ae1eea1051fd Reviewed-on: http://gerrit.openafs.org/10531 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Deorbit the netscape plugin Netscape hasn't been a thing since 2008. We would only try to build it if someone manually ran 'webinstall' in src/libuafs, and there is no documentation telling anyone to do so. It's dead, Jim. Change-Id: I7486ca33da7ff19f23f0d9f54f5fb4e7e3232540 Reviewed-on: http://gerrit.openafs.org/11470 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: D Brashear <shadow@your-file-system.com> Tested-by: D Brashear <shadow@your-file-system.com>
libafs: check afs_InitReq return code Do not ignore the return code from afs_InitReq everywhere it is called. If afs_InitReq fails, the vrequest could not be initialized for some reason. Change-Id: Ibae9f93c1e20a9fcae812f047da14106e6717454 Reviewed-on: http://gerrit.openafs.org/11097 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil> Reviewed-by: D Brashear <shadow@your-file-system.com>
Support for changes to OS X Mavericks VNOP_SYMLINK() function. Add support for an extra argument to afs_symlink() to return the newly-created symlink vnode if requested (this is needed on OS X Mavericks). On OS X Mavericks return the newly-created symlink vnode in the symlink vnops functions, on all other platforms ignore it. It turns out that technically OS X has required the symlink to be created for a while, but code inside of symlink() would call namei() on the symlink name if the returned vnode point was NULL. The difference is that on Mavericks the Manditory Access Control Framework has been enabled, and that turns on some extra code which unconditionally calls vnode_mount() on the returned vnode pointer, which ends up causing a panic Change-Id: I33b2f51cd10f76689eb9868eb05800ab493087c4 Reviewed-on: http://gerrit.openafs.org/10474 Reviewed-by: Derrick Brashear <shadow@your-file-system.com> Tested-by: BuildBot <buildbot@rampaginggeek.com>
libuafs: return error on symlink to self if we are symlinked to ourself directly, return ELOOP. Change-Id: I408012c4a9afb6bab0e917677c940f65ad59c697 Reviewed-on: http://gerrit.openafs.org/10240 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
libuafs: move code for uafs_LookupLink in order that we can make a future version static, move the code. Change-Id: I67e50ef5f14db3567ecd437b694b62b2c8fdb760 Reviewed-on: http://gerrit.openafs.org/10239 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Remove kauth from libuafs Remove the uafs_klog() apis from afs_usrops. Nothing uses it except the obsolete afsweb stuff that isn't built anymore. Stop linking in all kauth and pts components. Also remove some other objects from libauth, rxkad, and com_err, that were only present as dependencies of kauth and pts components Change-Id: Idf83b3dd1098e874d90244fe72609666b13216a4 Reviewed-on: http://gerrit.openafs.org/9887 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com> Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
uafs: avoid type-punning in get_user_struct() There's no need for type-punning here; usr_getspecific() is a macro that just assigns to the variable whose address we provide, so the cast was just unnecessary (and erroneous) obfuscation. This is the only caller of usr_getspecific(), so if it needs to be more complex in the future, it should probably just be open-coded here. Change-Id: I81286cbce9a00908aa87073b728b07d8bcc8d1d1 Reviewed-on: http://gerrit.openafs.org/7799 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementix.org>
uafs: avoid unnecessary type-punning There's no need to declare a separate buffer and initialize a structure inside it when we can just instantiate the structure directly. Change-Id: Idbcad31343ce7f074015f5921a4997d3f6c9799a Reviewed-on: http://gerrit.openafs.org/7798 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com> Reviewed-by: Derrick Brashear <shadow@dementix.org>
Unix CM: Don't cast allocator returns All of our allocators return (void *) values, so there is no need to cast the returns - doing so is just noise. Change-Id: I6b1009efbb5034225a4af0e19d03b74c628dfb82 Reviewed-on: http://gerrit.openafs.org/7457 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementix.org>
ukernel: add uafs_access we don't have an access vop. add one. Change-Id: I813fb941608b5e49a0f23730414854602630fdee Reviewed-on: http://gerrit.openafs.org/5589 Reviewed-by: Derrick Brashear <shadow@dementix.org> Tested-by: Derrick Brashear <shadow@dementix.org>