openafs.git
15 months agoafs: Remove dead assignments 22/15222/5
Kailas Zadbuke [Wed, 14 Dec 2022 14:00:24 +0000]
afs: Remove dead assignments

Clang scan-build reported variables being assigned value but not used.

In afs_NoCacheFetchProc() in file afs_bypasscache.c, delete the early
unused assignment of 'pp' and move the declaration of 'pp' closer to
where it's used. Also, 'ciov' is now unused and should be deleted.

In afs_GetDCache() in file src/afs/afs_dcache.c, value stored at line
2562 in 'code' is never read. Hence we can remove it. Also
value stored in variable 'i' is not used, so we can delete the
following line.
        i = osi_Time();

Also in afs_dcacheInit(), in file src/afs/afs_dcache.c, value stored in
variable 'ablocks' is not used, hence we can delete the following line.
        ablocks = afiles * (AFS_FIRSTCSIZE / 1024);

Thanks Indira Sawant(indira.sawant@ibm.com) for working with me on this
patch.

Change-Id: Ic6f72e3f8b0f0a69c9bf3dfa064db76423620796
Signed-off-by: Kailas Zadbuke <kailashsz@in.ibm.com>
Reviewed-on: https://gerrit.openafs.org/15222
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

15 months agoLinux: Replace lru_cache_add with folio_add_lru 27/15227/2
Cheyenne Wills [Wed, 14 Dec 2022 20:40:48 +0000]
Linux: Replace lru_cache_add with folio_add_lru

The Linux 6.2 commit:
    "folio-compat: remove lru_cache_add()" (6e1ca48d0)
removed the lru_cache_add() function (which was introduced in Linux 5.8)

The replacement function is folio_add_lru(), which was introduced with
the Linux 5.16 commit:
    "mm/lru: Add folio_add_lru()" (0d31125d2d)

Change-Id: I4615e6bde0253618c13ec1eb067e23b2c3e3ff42
Reviewed-on: https://gerrit.openafs.org/15227
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agoUKERNEL: avoid double include of roken.h 30/15130/4
Cheyenne Wills [Mon, 19 Sep 2022 22:25:13 +0000]
UKERNEL: avoid double include of roken.h

Commit 'afs: Replace strcpy &co by safer alternatives' (419f0cd7aa75719)
added an include for roken.h into UKERNEL/afsincludes.h.  Neither
UKERNEL/afsincludes.h or roken.h has a guard against a double include,
which can result in a build failure on older kernels (discovered on a
2.6.18 build):

 In file included from ~/openafs/src/afs/UKERNEL/afsincludes.h:30,
          from ~/openafs/src/afs/UKERNEL/afs_usrops.h:15,
          from ~/openafs/src/afs/UKERNEL/afs_usrops.c:24:
 include/roken.h:89: error: redefinition of typedef 'rk_socket_t'
 include/roken.h:89: error: previous declaration of 'rk_socket_t' was here
 In file included from ~/openafs/src/afs/UKERNEL/afsincludes.h:30,
          from ../afs/afsincludes.h:16,
          from ../afs/afs_bypasscache.h:68,
          from ~/openafs/src/afs/UKERNEL/afs_usrops.c:30:

Since roken.h is from an external source, we cannot update it to add
the necessary check.

Update UKERNEL/afsincludes.h to add a check to see if it has already
been included.

auth/ktc.c has a required include for roken.h, but it also can pull in
UKERNEL/afsincludes.h as well.  This can result in a double include for
roken.h.

Update auth/ktc.c to only include roken.h if not building UKERNEL.

Change-Id: I192443006f6c2257de57b35a6580b1df358c011c
Reviewed-on: https://gerrit.openafs.org/15130
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agoviced: cope with signed length/position in FetchData 23/15223/2
Benjamin Kaduk [Sat, 9 Oct 2021 03:11:19 +0000]
viced: cope with signed length/position in FetchData

For legacy reasons, the "Pos" (initial position) and "Len" (length)
inputs to the RXAFS_FetchData and RXAFS_FetchData64 RPCs are represented
as signed integers (the corresponding StoreData RPCs use unsigned values).

The use of signed values allows for the possibility of negative inputs,
and of signed integer overflow (undefined behavior in C), though the latter
is unlikely to arise naturally given that the implementation uses a
common backend with 64-bit values.

In particular, if a negative "Pos" value is supplied, we end up in
FetchData_RXStyle() that performs either FDH_PREAD() or FDH_PREADV()
with the negative value as the position from which to read, which is
an error.  The error handling for those calls treats any error as
indicative of a problem with the volume or its underlying storage,
and takes the volume offline for salvage.  Furthermore, after the
maximum number of automatic salvages the volume is left offline for
administrator action.  This presents a simple route for
(unauthenticated) denial of service, as root.cell.readonly must be
available to all users of the cell, and can be brought offline in this
way; rendering root.cell.readonly unavailable would bring essentially
all access to the cell to a halt.  (Other volumes could be targeted as
well, subject to their corresponding ACLs.)

Since there is no valid use for a negative position or length input,
reject them outright from the common_FetchData64() implementation.
Also check for whether the combination requests a read that would
overflow a signed integer and reject that as well.

Thanks to Jeffrey Altman and Chaskiel Grundman for collaborating on
this change.

FIXES 135263

Change-Id: I99c4c264c846b01fbbf4fecc60b1f34504bcc977
Reviewed-on: https://gerrit.openafs.org/15223
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agoLinux: Check for block_dirty_folio 99/15199/5
Cheyenne Wills [Fri, 18 Nov 2022 15:41:50 +0000]
Linux: Check for block_dirty_folio

The build for the openafs Linux kernel module fails on RHEL9.1 with an
undefined function reference for block_dirty_folio().

RedHat 9.1 includes the Linux commit:
  fs: Add aops->dirty_folio (6f31a5a261db)
which added the dirty_folio member to the address_space_operations
structure.

However RedHat 9.1 does not include the following 2 Linux commits:
  fs: Convert __set_page_dirty_buffers to block_dirty_folio (e621900ad2)
which introduced block_dirty_folio() as a function that could be used to
handle the address_space_operations's dirty_folio operation.

And
  fs: Remove aops ->set_page_dirty (3a3bae50af)
which removed the set_page_dirty member in the address_space_operations
structure.

The openafs commit:
  Linux-5.18 replace set_page_dirty with dirty_folio (6aa129e743e88)
introduced an autoconf test that checks for the presence of aops'
dirty_folio member and assumed that the Linux function
block_dirty_folio() was also provided (since all three of the above
Linux commits were added in Linux-5.18-rc1).

Without the (e621900ad2) commit, the openafs Linux kernel module fails
to build since block_dirty_folio() is not defined by Linux.

Introduce new autoconf tests that checks for the presence of the
block_dirty_folio() function.

Change the preprocessor conditional within LINUX/osi_vnodeops.c to only
use dirty_folio if aops has dirty_folio and block_dirty_folio() is
available.  When block_dirty_folio() is not available, we continue to
use the older set_page_dirty method, which remains a valid method until
its removal by the (3a3bae50af) Linux commit.

Note: Reviewing the Linux source for RedHat 9.1 shows that there is only
one location that is defining the dirty_folio member and it is providing
its own function instead of relying on block_dirty_folio.

Change-Id: If8f7bba3fa779e344ba1d51f7a837197586142bd
Reviewed-on: https://gerrit.openafs.org/15199
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agoviced: Remove dead assignments 88/15188/7
Indira Sawant [Wed, 2 Nov 2022 14:18:39 +0000]
viced: Remove dead assignments

Clang scan-build reported variables being assigned value but not used.

src/viced/host.c:
    >> Dead assignment: Value stored to 'code' is never read

Remove the assigned values that are never used.

Myself(indira.sawant@ibm.com) and Kailas Zadbuke(kailashsz@in.ibm.com)
worked on this together and submitting this patch.

Change-Id: Ia74aa6df1e918d7f07755c606571eb01d518b482
Signed-off-by: Indira Sawant <indira.sawant@ibm.com>
Reviewed-on: https://gerrit.openafs.org/15188
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

16 months agoLinux: Fix functions without prototypes 94/15194/5
Cheyenne Wills [Fri, 4 Nov 2022 14:33:39 +0000]
Linux: Fix functions without prototypes

The Linux kernel build has -Wstrict-prototypes enabled and flags
functions without a proper prototype.  With clang-16 these warnings are
reported as errors when the kernel is configured with CONFIG_WERROR or
when openafs is configured with --enable-checking.

    src/libafs/MODLOAD-6.1.0-rc3-SP/osi_alloc.c:339:32: error: a
       function declaration without a prototype is deprecated in all
       versions of C [-Werror,-Wstrict-prototypes]
   osi_linux_verify_alloced_memory()
                                  ^
                                   void

Update function prototypes to comply with -Wstrict-prototypes.

There are no functional changes with this commit.

Change-Id: I31aeb6e40bd3c6d9bf519d80bbed9b031b99df84
Reviewed-on: https://gerrit.openafs.org/15194
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agocf: Handle autoconf linux checks with -Werror 91/15191/7
Cheyenne Wills [Thu, 1 Dec 2022 21:18:36 +0000]
cf: Handle autoconf linux checks with -Werror

When the linux kernel has been configured with CONFIG_WERROR=y, several
autoconf configure checks used to detect linux features fail due to the
compiler performing additional coding checks (e.g. unused variables,
uninitialized variables, etc.).  Typically these additional coding
checks produce compiler warnings, but with CONFIG_WERROR=y these
warnings are reported as compiler errors, resulting in a misconfigured
build environment.

When testing for kernel features, turn off -Werror in the autoconf
functions AC_CHECK_LINUX_BUILD and AC_CHECK_LINUX_FUNC by explicitly
setting the compiler '-Wno-error' flag.

In addition, fix the commented description for AC_CHECK_LINUX_BUILD to
match the actual parameters

Change-Id: I2bc4f6accdc82d12484654ef1185e3970bd9a04f
Reviewed-on: https://gerrit.openafs.org/15191
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

16 months agocf: Skip RRA_LIB_GSSAPI if krb5/gss is disabled 38/15138/2
Andrew Deason [Tue, 13 Sep 2022 17:23:22 +0000]
cf: Skip RRA_LIB_GSSAPI if krb5/gss is disabled

Currently, we always run RRA_LIB_GSSAPI during configure, even if we
already detected that there is no libkrb5 available or
--without-gssapi was given. This means that no matter what options the
user passes, 'configure' throws an error if we can't find a usable
gssapi library.

Our logic in gss.m4 is structured similarly to krb5.m4, which assumes
that the probing macro (RRA_LIB_KRB5_OPTIONAL / RRA_LIB_GSSAPI) does
effectively nothing if the relevant library is not available. But
RRA_LIB_GSSAPI behaves like RRA_LIB_KRB5, not RRA_LIB_KRB5_OPTIONAL,
in that it throws an error and stops 'configure' if it cannot find a
usable gssapi library. (Currently, there is no RRA_LIB_GSSAPI_OPTIONAL
macro like there is for krb5.)

To fix this, just skip RRA_LIB_GSSAPI if we've already detected that
there is no krb5 library available, or if gss has been explicitly
disabled with --without-gssapi.

Based on a commit by cwills@sinenomine.net.

Change-Id: I08951a9b78f5edb88018cd3991b0213561ff94b2
Reviewed-on: https://gerrit.openafs.org/15138
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agocf: Detect how to pass CFLAGS to linux kbuild 96/15196/8
Cheyenne Wills [Thu, 1 Dec 2022 19:55:26 +0000]
cf: Detect how to pass CFLAGS to linux kbuild

The autoconf test LINUX_KBUILD_USES_EXTRA_CFLAGS fails on modern kernels
when detecting how to pass CFLAGS to the compiler when building a Linux
kernel module.  The result of this test is used by configure when
testing for Linux kernel features.

In addition the EXTRA_CFLAGS method of passing compiler parameters has
been deprecated since Linux 2.6.24 commit:
    "kbuild: introduce ccflags-y, asflags-y and ldflags-y" (f77bf01425b)

The currently preferred method is to use the make variable 'ccflags-y'
to set compiler flags.

Replace the autoconf function LINUX_KBUILD_USES_EXTRA_CFLAGS with a new
test, LINUX_KBUILD_FIND_CFLAGS_METHOD, that checks the various ways to
pass compiler flags when building the kernel module.

Set the build variable "LINUX_KBUILD_CFLAGS_VAR" with the determined
method for setting kbuild compiler flags.

Update the AC_TRY_KBUILD26 autoconf function and the
make_kbuild_makefile.pl script to use the determined method for setting
the compiler flags for the kbuild process.

Background:

The autoconf test, LINUX_KBUILD_USES_EXTRA_CFLAGS, is used to determine
when to use either CFLAGS for EXTRA_CFLAGS when performing other
autoconf tests for Linux kernel features. The test was added with the
openafs commit:
 "linux-2624-20071123" (af7cf697ef8)

LINUX_KBUILD_USES_EXTRA_CFLAGS relied on the Linux 2.6.24 commit:
 "kbuild: check for wrong use of CFLAGS" (0c53c8e6eb4)
which caused a build failure if CFLAGS where used instead of
EXTRA_CFLAGS.

Later with the Linux 4.20 commit:
 "kbuild: remove old check for CFLAGS use" (0d91bf584fe)
which removed the build failure when CFLAGS were set and this resulted
in LINUX_KBUILD_USES_EXTRA_CFLAGS failing to properly determining how to
set compiler flags in the kbuild process.

As mentioned above, the EXTRA_CFLAGS method itself has been deprecated
in Linux 2.6.24, but support for using it has still present in the
kbuild processes.

Change-Id: I8ce3a8c9af4785ae85d0bbd5962c573a35d8748e
Reviewed-on: https://gerrit.openafs.org/15196
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agolibadmin: Fix RPCStatsStateGet 'rpc' prototype 80/15180/5
Cheyenne Wills [Thu, 1 Dec 2022 17:00:06 +0000]
libadmin: Fix RPCStatsStateGet 'rpc' prototype

clang-16 is flagging a incompatible-function-pointer-types warning which
results in build errors when --enable-warning is turned on.

   client.c:498:13: error: incompatible function pointer types passing
      'int (struct rx_connection *, afs_int32 *)'
      (aka 'int (struct rx_connection *, int *)') to parameter of type
      'int (*)(struct rx_connection *, afs_RPCStatsState_p)'
      (aka 'int (*)(struct rx_connection *, afs_RPCStatsState_t *)')
      [-Wincompatible-function-pointer-types]

    (conn, RXSTATS_QueryPeerRPCStats, &state, &st)) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~

Update the 'util_RPCStatsStateGet()' function's parameter to match the
function type for the RPC functions actually being called.

Change-Id: I4354dff2733ce2319b27a2f047cfe4a21ef3bcc8
Reviewed-on: https://gerrit.openafs.org/15180
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agoclang-16: Fix simple unused-but-set variables 78/15178/5
Cheyenne Wills [Thu, 1 Dec 2022 19:09:09 +0000]
clang-16: Fix simple unused-but-set variables

Clang-16 is flagging variables as unused-but-set-variables resulting in
build errors when --enable-warning is used.

   db_verify.c:996:9: error: variable 'builtinUsers' set but not used
      [-Werror,-Wunused-but-set-variable]
       int builtinUsers = 0;
           ^
Remove the variables that are set but never actually used.

This commit fixes the simpler cases where variables are only set but
not used elsewhere.

Change-Id: I45674871cfc70a7e57c7c3e2d74ec81a4433a7c4
Reviewed-on: https://gerrit.openafs.org/15178
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agoclang-16: Fix conditionally unused-but-set variables 77/15177/5
Cheyenne Wills [Wed, 2 Nov 2022 20:47:04 +0000]
clang-16: Fix conditionally unused-but-set variables

clang-16 is flagging unused-but-set variables which result in build
errors when --enable-warning is turned on.

   remote.c:485:15: error: variable 'pass' set but not used
       [-Werror,-Wunused-but-set-variable]
     afs_int32 pass;
              ^
These variables are actually used in specific cases depending on
build configuration (e.g. AFS_PTHREAD_ENV, etc.).

Relocate these variables so they are fully defined or referenced within
preprocessor '#if' blocks.

Change-Id: I900a192ec781be4ab4453769e1d8f0cc48fe5757
Reviewed-on: https://gerrit.openafs.org/15177
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

16 months agoclang-16: Fix unused-but-set 'for' control vars 76/15176/5
Cheyenne Wills [Thu, 1 Dec 2022 16:05:58 +0000]
clang-16: Fix unused-but-set 'for' control vars

clang-16 is flagging unused-but-set variables which result in build
errors when --enable-warning is turned on.  Several of these variables
are used within 'for(..)' loops but are not actually referenced anywhere
else.

  fcrypt.c:181:16: error: variable 'i' set but not used
     [-Werror,-Wunused-but-set-variable]
    afs_uint32 i, j;
               ^
Refactor the for statements to eliminate the unused variables.

Note, this commit is a little more complex than simply removing unused
variables.

Change-Id: I4d2de60dffc3e717d784e820f2d91470c5e7926b
Reviewed-on: https://gerrit.openafs.org/15176
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agocrypto: Define krb5_keytype as krb5_enctype 89/15189/8
Cheyenne Wills [Mon, 14 Nov 2022 22:55:41 +0000]
crypto: Define krb5_keytype as krb5_enctype

When building with clang-16 and configured with --enable-checking, the
external source heimdal/krb5/crypto.c used in src/crypto/rfc3961 fails
with the following error:

  src/external/heimdal/krb5/crypto.c:702:28
   error: implicit conversion from enumeration type 'krb5_enctype' (aka
   'enum ENCTYPE') to different enumeration type 'krb5_keytype' (aka
   'enum krb5_keytype') [-Werror,-Wenum-conversion]
       *keytype = e->keytype->type; /* XXX */
                ~ ~~~~~~~~~~~~^~~~

Replace the enum definition of krb5_keytype with a typedef to
krb5_enctype and create an anonymous enum mapping of KEYTYPE_ARCFOUR to
ETYPE_ARCFOUR_HMAC_MD5.

It should be noted that krb5_keytype and KEYTYPE_ARCFOUR are only used
by the external file src/external/heimdal/krb5/crypto.c

Changing the type for krb5_keytype was suggested by Andrew Deason
(adeason@sinenomine.net).

Change-Id: I6b4e94cabe98f9b33df0c91cb75bc84b9f9e3dee
Reviewed-on: https://gerrit.openafs.org/15189
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agodumptool: Remove unused 'sflag' variable 81/15181/4
Cheyenne Wills [Wed, 2 Nov 2022 20:53:21 +0000]
dumptool: Remove unused 'sflag' variable

clang-16 is flagging unused-but-set variables which result in build
errors when --enable-warning is turned on.

   ./dumptool.c:1285:54: error: variable 'sflag' set but not used
      [-Werror,-Wunused-but-set-variable]
       int errflg = 0, lflag = 0, iflag = 0, Fflag = 0, sflag = 0, Rflag = 0;

Within dumptool the '-s' option of the 'ls' subcommand sets the 'sflag'
variable, but the variable itself is never used anywhere else.

Remove the variable 'sflag', and ignore the '-s' option.

The sflag variable was unused in the commit that introduced the code:
"test-suite-pull-tools-directly-in-20020114" (fcb32c07ed6d)

Change-Id: I0769b9d3f76b4a802109628496bf332618162f89
Reviewed-on: https://gerrit.openafs.org/15181
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

16 months agolibuafs: include com_err.h in ukernel_swig.i 79/15179/4
Cheyenne Wills [Fri, 28 Oct 2022 23:53:15 +0000]
libuafs: include com_err.h in ukernel_swig.i

clang-16 is flagging an implicit-function-definition which results in a
build error when --enable-warning is turned on.

    PERLUAFS/ukernel_swig_perl.c:1585:9: error: call to undeclared
        function 'afs_com_err'; ISO C99 and later do not support
        implicit function declarations [-Wimplicit-function-declaration]
      afs_com_err("AFS::ukernel", code, "parsing line: '%s'", line);
      ^

Add an include for afs/com_err.h to resolve the warning.

Change-Id: Id02d8a3f0ec6d7d3a9f5ffe7fcacf1a6972700a0
Reviewed-on: https://gerrit.openafs.org/15179
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

17 months agorx: Remove event_handler rx_pthread_* counters 75/15175/6
Cheyenne Wills [Fri, 4 Nov 2022 14:24:09 +0000]
rx: Remove event_handler rx_pthread_* counters

The event_handler() function contains several counters that are
set and incremented but are not actually used.  Clang-16 is flagging
these with a 'unused-but-set-variable' warning resulting in build errors
when --enable-warnings is used.

rx_pthread.c:136:19: error: variable 'rx_pthread_n_event_expired' set
       but not used [-Werror,-Wunused-but-set-variable]
      unsigned long rx_pthread_n_event_expired = 0;

Several 'if' statements are used to conditionally set these variables,
but serve no other purpose. These 'if' statements can also be
eliminated.

Remove the unused rx_pthread_* counter variables as well as the
associated 'if' statements.  In addition the only purpose of the
'error' variable was to conditionally increment one of the removed
variables, remove the 'error' variable.

These variables have been 'unused but set' since the original commit
from IBM.

Change-Id: Ibad026cef2030c89a9421b1eea64049ef38fe37e
Reviewed-on: https://gerrit.openafs.org/15175
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

17 months agomacOS: Add support for aarch64-*-darwin* sysname 49/15149/6
Ganesh Chaudhari [Fri, 7 Oct 2022 13:43:34 +0000]
macOS: Add support for aarch64-*-darwin* sysname

As of libtool 2.4.7, the supplied config.guess file modifies
the sysname returned on macOS arm64 from arm-*-darwin* to
aarch64-*-darwin*. As a result, trying to build OpenAFS on
macOS arm64 fails with the following message:

  configure: error: An AFS sysname is required

To avoid this problem, added support for aarch64-*-darwin*.

Change-Id: Id00d5a749ffb9ef49f0ebba6d8b9a47c5c3a9d6a
Signed-off-by: Ganesh Chaudhari <gangovind@in.ibm.com>
Reviewed-on: https://gerrit.openafs.org/15149
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

17 months agoINSTALL: Update INSTALL to reflect AIX platforms 42/15142/6
Ben Huntsman [Thu, 25 Aug 2022 18:58:31 +0000]
INSTALL: Update INSTALL to reflect AIX platforms

Update the INSTALL file to reflect the current rs_aix platforms
that we can build for.

Change-Id: I6d8a0376df5507c9ecfdffbd32e86610130af28d
Reviewed-on: https://gerrit.openafs.org/15142
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

17 months agoAIX: Fix issue with make install on AIX 7.1 and higher 46/15146/6
Ben Huntsman [Thu, 25 Aug 2022 21:53:00 +0000]
AIX: Fix issue with make install on AIX 7.1 and higher

Added rules to src/export/Makefile.in for the install target
under AIX 7.1 and higher.

Change-Id: I5472c491f1eb93b468aa5dad36baf7cac8c43a6a
Reviewed-on: https://gerrit.openafs.org/15146
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

17 months agomacos: Update postinstall instructions for MacOS 13 50/15150/4
Ganesh Chaudhari [Fri, 7 Oct 2022 16:22:40 +0000]
macos: Update postinstall instructions for MacOS 13

System preferences is getting replaced by System settings in MacOS 13.
So, this commit will address the required changes in the dialog box
which gets popped after installing OpenAFS.

Change-Id: I56ddb1d43ef5994ac30d5383bf8a376b43419724
Signed-off-by: Ganesh Chaudhari <gangovind@in.ibm.com>
Reviewed-on: https://gerrit.openafs.org/15150
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

17 months agorxkad: Consolidate refCount decrement 53/15153/2
Andrew Deason [Wed, 12 Oct 2022 19:42:33 +0000]
rxkad: Consolidate refCount decrement

To make code changes easier, all rxkad code that deals with
incrementing/decrementing the rx_securityClass refCount should be done
in the same place. Right now, there's only one incrementing code path,
but there are two decrement code paths that are duplicated. Change the
rxkad_DestroyConnection refCount-handling logic to just call
rxkad_Close(), since the behavior is identical.

Change-Id: Ibee79435dc62d79f0094ead818566c7f62c91898
Reviewed-on: https://gerrit.openafs.org/15153
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

17 months agorxgk: Use 'dir' as rock in afsconf_BSSO_int 52/15152/2
Andrew Deason [Tue, 18 Oct 2022 21:43:43 +0000]
rxgk: Use 'dir' as rock in afsconf_BSSO_int

Commit 2630e70550 (Move key-related warnings to common server code)
changed afsconf_BuildServerSecurityObjects into
afsconf_BuildServerSecurityObjects_int, and changed some arguments,
including removing the 'rock' arg. Specify 'dir' instead of 'rock'
here (they're the same thing), so we can build with rxgk again.

Change-Id: I7e8f979ec42b3b0f2af249da79f1ad30040a1a00
Reviewed-on: https://gerrit.openafs.org/15152
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

18 months agoconfigure: Add platform rs_aix71 43/15143/5
Ben Huntsman [Thu, 25 Aug 2022 19:00:51 +0000]
configure: Add platform rs_aix71

Enable the configure script to detect and configure AIX 7.1.

Change-Id: I746cc00ff43b061c1950785279549a3512ff7303
Reviewed-on: https://gerrit.openafs.org/15143
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

18 months agolibafs: Add support for AIX 7.1, 7.2 45/15145/4
Ben Huntsman [Thu, 25 Aug 2022 21:23:51 +0000]
libafs: Add support for AIX 7.1, 7.2

src/libafs/MakefileProto.AIX.in contains rules for various versions of
AIX, but did not have any case for AIX 7.1 or 7.2  This causes build
failures on those platforms.  Added in the missing entries for rs_aix71
and rs_aix72.

Change-Id: I92625223b7b467e328e9eeeff2feef4e253345e2
Reviewed-on: https://gerrit.openafs.org/15145
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

18 months agoAIX: Correctly create export64.exp on AIX 7.1+ 44/15144/4
Ben Huntsman [Thu, 25 Aug 2022 20:15:11 +0000]
AIX: Correctly create export64.exp on AIX 7.1+

Create the export64.exp file on AIX 7 and higher.

Change-Id: I46a631586819354870a4b23cbde44942daf5a09b
Reviewed-on: https://gerrit.openafs.org/15144
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

18 months agoviced: Use calloc for fsstate data 25/14725/4
Mark Vitale [Fri, 17 Jul 2020 15:58:25 +0000]
viced: Use calloc for fsstate data

Internal struct fs_dump_state contains a number of pointer members to
other internal headers that are allocated via malloc, and later zeroed
or read in from disk. Use calloc instead (and remove some of the
now-redundant memsets) to make sure we never accidentally use the
uninitialized memory.

While here, also use sizeof the member names rather than the member
types.

[adeason@sinenomine.net: Removed some memsets.]

Change-Id: Ia78bd3956a6367b8f16b01c1b3181875df47ba87
Reviewed-on: https://gerrit.openafs.org/14725
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

18 months agomacos: Add support for MacOS 13.0 (Ventura) 39/15139/4
Ganesh Chaudhari [Wed, 14 Sep 2022 10:27:27 +0000]
macos: Add support for MacOS 13.0 (Ventura)

This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on OS X 13.0 “Ventura”.

Thank you Kailas Zadbuke (IBM) and Harish Sharma (IBM) for your help.

Change-Id: Ice01b93fb6bbdee433fe1b3260e5e7f74a31930a
Reviewed-on: https://gerrit.openafs.org/15139
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

18 months agoLinux-6.0: Replace add_to_page_cache 32/15132/4
Cheyenne Wills [Thu, 22 Sep 2022 19:04:59 +0000]
Linux-6.0: Replace add_to_page_cache

Linux 6.0 removed the add_to_page_cache function in the Linux commit:
    'filemap: Remove add_to_page_cache() and add_to_page_cache_locked()'
    (2bb876b58d593d7f2522ec0f41f20a74fde76822)

The replacement function, filemap_add_folio function is exported as GPL,
but a non-GPL wrapper was provided in the Linux 5.15 commit:
    'mm/filemap: Add filemap_add_folio()'
    (9dd3d069406cea073fc633e77bc59abbfde8c6c4)
which changed the GPL exported function add_to_page_cache_lru to a
non-GPL exported function.

The function add_to_page_cache_lru functionally combines the
add_to_page_cache with lru_cache_add.  Within afs, all the calls to
add_to_page_cache follow the pattern of calling the lru_cache_add
via the wrapper afs_lru_cache_add immediately after (except in one case
noted below).

Add an autoconf check to see if add_to_page_cache_lru is available.

Introduce a new wrapper function afs_add_to_page_cache_lru that handles
calling either add_to_page_cache/afs_lru_cache_add or
add_to_page_cache_lru.

As noted above there is one function, afs_linux_bypass_readpages, that
calls add_to_page_cache but does not immediately call afs_lru_cache_add.
This function is only used in Linux kernels prior to 5.18, see the
commit:
    'Linux-5.18: replace readpages with readahead' (7a181415db)
Since this code path is only built for a Linux kernel level where
add_to_page_cache should also exists, we do not replace this call.

NOTE:
The add_to_page_cache_lru was moved into mm/folio-compat.c which has a
comment indicating that callers of these functions should migrate to
folio calls.  However the replacement folio call that is needed by afs,
filemap_add_folio, is exported as GPL.

Change-Id: I10087ebeb8b08309e6c1bab4fc43f7e9f50bd105
Reviewed-on: https://gerrit.openafs.org/15132
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

18 months agoafs: Use strlcat instead of snprintf to enable AIX build 22/15122/8
Ben Huntsman [Tue, 23 Aug 2022 20:15:46 +0000]
afs: Use strlcat instead of snprintf to enable AIX build

The original code used strcpy(), etc.  Some compilers have begun
to raise warnings that the use of these functions is unsafe, and
in the case of newer Linux kernels in particular, have caused the
build to fail outright.  To adapt to these compilers/kernels, the
code was changed to leverage strlcpy(), snprintf(), etc. as they
are safer.  AIX does not provide these functions within the
kernel.  For some of the functions such as strlcpy(), etc. we
can use replacement functions from libroken within the AIX kernel
extension.  However, libroken does not offer a suitable
replacement for snprintf(), and instead the same purpose can be
accomplished by using strlcpy() and multiple calls to strlcat().

Change-Id: Iae4b9d945b12dea88727a3453d06b8ff1eb285ae
Reviewed-on: https://gerrit.openafs.org/15122
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

18 months agorx: Only use printf in the AIX kernel 18/15118/8
Ben Huntsman [Thu, 18 Aug 2022 00:19:55 +0000]
rx: Only use printf in the AIX kernel

An earlier version of the OpenAFS code used an unusual preprocessor
macro for the function osi_Msg and osi_VMsg.  This causes problems
on newer Linux kernels.  The macro was replaced with a function
leveraging vprintf, etc.  These functions are not available in the
AIX kernel, where our only option is printf.  However, AIX does
provide these functions in libc.  This change ensures we only use
printf when building the AIX kernel module.

Change-Id: Ib46c4712516846a489cc66fda0833907612b3316
Reviewed-on: https://gerrit.openafs.org/15118
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

18 months agoBUILD: Ensure that make clean actually cleans all products 19/15119/5
Ben Huntsman [Fri, 19 Aug 2022 15:34:33 +0000]
BUILD: Ensure that make clean actually cleans all products

After a build, running make clean leaves the following objects:

src/dir/test/dtest.o
src/libuafs/libuafs.a
src/libuafs/*.o
src/roken/*.o

Add a few rules to the various Makefiles to ensure that we clean
up those files as well.

Change-Id: I4fb3346b68aa9e20164952d9461c39664020ef7f
Reviewed-on: https://gerrit.openafs.org/15119
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

19 months agoafs: Fix missing def for pinned_heap on AIX 08/15108/4
Ben Huntsman [Sat, 13 Aug 2022 18:40:44 +0000]
afs: Fix missing def for pinned_heap on AIX

Include sys/malloc.h in AIX's osi_sleep.c.  This resolves a build
failure in which pinned_heap is not defined.

The commit below introduced code to resolve an issue on AIX 5.3:

  5e5bfa6b9401ebc1fa5446e208cf46c15943c411
  Author: Tom Keiser <tkeiser@sinenomine.net>
  Date:   Mon Jun 25 21:22:49 2007 +0000

    aix53-avoid-wait-crash-20070625

newp = (afs_event_t *) xmalloc(sizeof(afs_event_t), 5, pinned_heap);

pinned_heap has always been defined in sys/malloc.h since at least
AIX 4.1.  It is likely that the aix53-avoid-wait-crash-20070625
commit did not compile, or that sys/malloc.h was included
elsewhere at the time.

Change-Id: If4c026ae06f8a6bba1cc78af991d1adef5102f3f
Reviewed-on: https://gerrit.openafs.org/15108
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

19 months agoAIX: Fix install of 64-bit kernel module 14/15114/4
Ben Huntsman [Mon, 15 Aug 2022 17:44:14 +0000]
AIX: Fix install of 64-bit kernel module

Remove make step in error.  This was preventing the install of the
built kernel module on AIX when not using Transarc-style paths via
the make install step.

Change-Id: I870de97124a320f6d996aece803ecd4b36bf787f
Reviewed-on: https://gerrit.openafs.org/15114
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

19 months agoutil: Add missing symbol for AIX build 13/15113/5
Ben Huntsman [Mon, 15 Aug 2022 17:00:07 +0000]
util: Add missing symbol for AIX build

Added symbol afs_exec_alt to liboafs_util.la.sym.  This resolves a
build failure on AIX.

Change-Id: I98c3478bfe041db38b929bd6e2036e9d3038e9e1
Reviewed-on: https://gerrit.openafs.org/15113
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

19 months agofsint: export symbol needed by fileserver 12/15112/5
Ben Huntsman [Sun, 14 Aug 2022 06:25:10 +0000]
fsint: export symbol needed by fileserver

The symbol RXAFS_OpCodeIndex is consumed by the fileserver via the various
"opcode_<RPC Name>" macros produced by rxgen.  The functionality is provided
by liboafs_fsint but RXAFS_OpCodeIndex was omitted from the export symbol list.
This went undetected because we use static linking for the fileserver, and
libtool does not enforce export symbol lists while static linking, on platforms
other than AIX.  Recent efforts to revive the AIX build illuminated the error,
which we resolve by adding RXAFS_OpCodeIndex to the export list.

Change-Id: Ie5b3e5a7a714cfe4b1657b9bbac248c47abbe194
Reviewed-on: https://gerrit.openafs.org/15112
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

19 months agoexport: Ignore additional build products generated on AIX 10/15110/5
Ben Huntsman [Sat, 13 Aug 2022 18:47:07 +0000]
export: Ignore additional build products generated on AIX

Update .gitignore to ignore additional build products generated on AIX.

Change-Id: I91cd1c3d9019e6de89db7f957807b3cbab09e874
Reviewed-on: https://gerrit.openafs.org/15110
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

19 months agodoc: Remove stray sect2 end tag 20/15120/3
Michael Meffie [Tue, 5 Jul 2022 21:16:41 +0000]
doc: Remove stray sect2 end tag

Commit 2f435309c75dfd8ffe0cfb3e1a54749437cba3be (Remove NoAuth
procedures from Admin Guide) introduced a syntax error in the Admin
Reference guide xml source.

The </sect2> end tag which matched the <sect2 id="Header_427"> start tag
should have been removed in the last hunk of that commit.

This change removes the stray end tag to fix the xsltproc error:

    Build the book set list...
    openafs/doc/xml/AdminGuide/auagd014.xml:1119: parser error : Opening and ending tag mismatch: sect1 line 1037 and sect2
        </sect2>
                ^
    ...
    Error: xsltproc failed
    make: *** [Makefile:42: auagd000.pdf] Error 1

Change-Id: I91b9b5335c2ddd6ab60d3bc061703c8396003a43
Reviewed-on: https://gerrit.openafs.org/15120
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agoLINUX: Use bitwise & for f_flags test 03/14903/6
Cheyenne Wills [Tue, 8 Mar 2022 01:35:03 +0000]
LINUX: Use bitwise & for f_flags test

This code is clearly supposed to be masking f_flags with O_ACCMODE, and
so should be using a bitwise &, not the boolean &&.  Clang complains
about this, causing a warning (which breaks the build with
--enable-checking):

error: use of logical '&&' with constant operand [-Werror,
        -Wconstant-logical-operand]
        } else if ((file->f_flags && O_ACCMODE) != O_WRONLY) {
                                  ^  ~~~~~~~~~
.../osi_vnodeops.c:3192:28: note: use '&' for a
        bitwise operation

For the current code without this commit the behavior of this
check is as follows:

   When f_flags is:         The check is:
   ====================     =============
   O_RDONLY                 True  (as expected)
   O_WRONLY                 False (as expected)
   O_RDWR                   False (incorrect)
   has some non-O_ACCMODE   False (incorrect)
    bit is set

The incorrect check doesn't cause any problems for overall correctness,
but it does mean that in those cases afs_linux_fillpage will not be
called and that partially-written pages will be left out of date and any
reader will need to fill the page again.

Fix this by using the bitwise &.

There is also an out of date link to the Linux documentation.  Update
the comment to point to the current documentation that is in the Linux
source tree.

Change-Id: I193b30e837075ef18d0559c6b28ac8ce222c1a5a
Reviewed-on: https://gerrit.openafs.org/14903
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agoautoconf: Additional library test for ncurses 89/14889/3
Cheyenne Wills [Wed, 9 Feb 2022 21:00:13 +0000]
autoconf: Additional library test for ncurses

Depending on how the ncurses libraries were built the external symbol
'LINES' may be replaced with the '_nc_LINES' external symbol.  Because
the symbol 'LINES' may or may not be present, the autoconf test can fail
to detect the correct libraries needed for curses support.

Add an additional AC_CHECK_LIBs for the symbol _nc_LINES (within the
ncurses or tinfo libraries) when setting the $LIB_curses.

This commit was adapted from the openSuSE source packaging for openafs.

Background: when ncurses is built with --enable-reentrant, LINES is
defined as a C preprocessor macro that expands to a call to _nc_LINES

Change-Id: If5e93078ff8cd0af5a50a25a8be7b462261a4f6f
Reviewed-on: https://gerrit.openafs.org/14889
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Ralf Brunckhorst <rbrunckhorst@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agoafs: Cleanup AFS_S390X_ENV statement 93/14993/6
Cheyenne Wills [Fri, 3 Jun 2022 19:22:19 +0000]
afs: Cleanup AFS_S390X_ENV statement

The commit 'Change AFS*_LINUXnn_ENV to AFS*_LINUX_ENV' (6329a523f6)
mechanically replaced the multiple versions of the AFS*_LINUXnn_ENV
definitions with non-versioned definitions.  A follow-on commit 'Cleanup
AFS_*LINUX_ENV usage' (cbc18e4b3) refactored code to handle cleaning up
redundant statements or removing dead code.

The clean up in cbc18e4b3 missed a block of preprocessor statements in
osi_probe.c which defined the macros _SS(x) and _SX(x).

Prior to the commit 6329a523f6, these macros performed bit shifting or
masking for the S390X LINUX20 environment.  For S390X LINUX24 or other
platforms the macros just emitted their parameter.

With commit 6329a523f6 the statement:
   #if defined(AFS_S390X_LINUX20_ENV) && !defined(AFS_S390X_LINUX24_ENV)
was replaced with (which dropped support for S390X LINUX20):
   #if defined(AFS_S390X_LINUX_ENV) && !defined(AFS_S390X_LINUX_ENV)

After cleaning up the conditional, the result leaves the definitions for
_SS and _SX as:
   #define _SS(x) (x)
   #define _SX(x) (x)

Which allows further cleanup by removing these macros and just using
their arguments directly.

Change-Id: I7b56c01ffd59e5f0220bf2a29e92a5cd41977b04
Reviewed-on: https://gerrit.openafs.org/14993
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agoexport: Install kernel utilities with execute permissions on AIX 16/15116/3
Ben Huntsman [Mon, 15 Aug 2022 21:45:12 +0000]
export: Install kernel utilities with execute permissions on AIX

Make sure that cfgexport and cfgafs are installed with execute
permissions.  These executables load the AIX kernel modules into
the running kernel and are called by the rc.afs script.

Change-Id: I9434a25dc03033cfcc268e763bf9122349eef3a4
Reviewed-on: https://gerrit.openafs.org/15116
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agoafs: Fix missing def for timestruc_t on AIX 07/15107/2
Ben Huntsman [Sat, 13 Aug 2022 18:40:18 +0000]
afs: Fix missing def for timestruc_t on AIX

Include sys/time.h in AIX's osi_machdep.h.  This resolves a build
issue where the struct timestruc_t was not defined.

Change-Id: I2acf770f8bfa226915d6257ff6a376ea11e515b9
Reviewed-on: https://gerrit.openafs.org/15107
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agorxevent: fix mismatched #endif 06/15106/2
Benjamin Kaduk [Tue, 16 Aug 2022 14:48:02 +0000]
rxevent: fix mismatched #endif

We should only assign to 'ev' once, rather than assigning a second
time to an uninitialized value.

Reported by Ben Huntsman and diagnosed by Jeffrey Altman.

Change-Id: I63f50d46658e95ae570dc78dcfeffce973a9e7ed
Reviewed-on: https://gerrit.openafs.org/15106
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agoviced: Verify primary host address 70/15070/4
Andrew Deason [Fri, 8 Jul 2022 22:14:26 +0000]
viced: Verify primary host address

Currently, h_stateVerifyHost verifies that all of the valid entries on
h->z.interface are on the host address hashtable. If we don't have a
h->z.interface, we check the primary address h->z.host/h->z.port
instead.

But if we do have a h->z.interface, we don't check h->z.host/h->z.port
at all. Normally, the primary address should always be included in the
h->z.interface list (in a 'valid==1' entry), and so checking the
primary address is redundant. However, currently it is possible in
some edge cases for the primary address to be missing from the
hashtable and to not be listed as a valid address in h->z.interface.
In such cases, we don't flag an error or even log a warning, since we
don't check the primary address separately. (These cases are bugs, and
will be addressed in future commits.)

To detect this case, change h_stateVerifyHost to always check
h->z.host, just like we do for the entries in h->z.interface.

Change-Id: Id88276dfd121194141cb493924bab8d50cb8fcf3
Reviewed-on: https://gerrit.openafs.org/15070
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agosystemd: do not load the 'openafs' module on boot 92/15092/2
Jan Iven [Fri, 5 Aug 2022 12:46:27 +0000]
systemd: do not load the 'openafs' module on boot

remove /etc/sysconfig/modules/openafs-client.modules, i.e no longer have
systemd run "modprobe openafs" at boot, on RPM-based systems.

This had been introduced with a reference to the Fedora packaging guide
at the time. However, this mechanism was meant just for persistent
driver modules (i.e expected to stay loaded over the runtime) - the
"openafs" module is loaded (and unloaded) by the actual systemd unit.

The systemd unit that processes the above file comes from "initscripts",
this is optional in later Fedoras/RHELs and so the file may not even be
processed (/usr/lib/modules-load.d/ would be an alternative mechanism to
load modules at boot.. if needed).

This change is mostly cosmetic, although RT#135204 showed that having
the "openafs" module loaded without a client running can actually be
harmful.

Change-Id: Iff1762723e25565268220403c383c7cc3fb4797a
Reviewed-on: https://gerrit.openafs.org/15092
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agoviced: Show correct port/valid in state_analyzer 66/15066/3
Andrew Deason [Fri, 8 Jul 2022 21:42:43 +0000]
viced: Show correct port/valid in state_analyzer

state_analyzer currently prints the port for 'host' entries directly.
The port is stored in network-byte order, though, so on little-endian
machines, the port is not displayed correctly.

Fix this by converting to host-byte order when printing. Also while
we're here, print the 'valid' field when showing AddrPort structs,
since we currently don't show it at all.

Change-Id: Id5049f37566f74287d71973957e25c1ffd64982d
Reviewed-on: https://gerrit.openafs.org/15066
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agobozo: Use buffered I/O to send notifier data 18/14818/8
Michael Meffie [Wed, 23 Jun 2021 18:51:52 +0000]
bozo: Use buffered I/O to send notifier data

Currently, popen() is used to open a pipe to the notifier program, then
notifier messages are formatted in memory then sent with unbuffered I/O,
then the pipe is immediately closed.

Instead of allocating buffers and formatting the notifier string, just
use the buffered stream.  Check for write errors with ferror(), and do
not ignore the pclose() return code.

Change-Id: Ib2bd692591171b4f380fc25bec56d4db898d883e
Reviewed-on: https://gerrit.openafs.org/14818
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

20 months agobozo: Set instance output parameters with strdup 33/14833/8
Michael Meffie [Tue, 19 Oct 2021 15:26:36 +0000]
bozo: Set instance output parameters with strdup

Use strdup() to allocate and copy the SBOZO_EnumerateInstance() and
SBOZO_GetInstanceInfo output strings, instead of preallocating buffers
and filling them with strcpy().  This avoids fixed size memory
allocation and a possible overflow from an unbounded string copy.

Commit ea276e83e3 (OPENAFS-SA-2019-001: Skip server OUT args on
error) is a prerequisite for this change.

Change-Id: I5b1df645b4ca8fbf42cd39d8c09a9af50d302ad1
Reviewed-on: https://gerrit.openafs.org/14833
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

20 months agobozo: Add bnode_GetNotifier() 97/14797/8
Michael Meffie [Wed, 8 Sep 2021 18:33:25 +0000]
bozo: Add bnode_GetNotifier()

Add the bnode_GetNotifier() function to retrieve the bnode's notifier
string, if one is set.  This is a refactoring change to improve code
clarity.

Change-Id: I5c5bb2e8349a3aaa65014a33fa0fdd691dc697dc
Reviewed-on: https://gerrit.openafs.org/14797
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

20 months agolinux: Call put_page if errors in aops->readpages 68/15068/5
Cheyenne Wills [Thu, 14 Jul 2022 19:03:08 +0000]
linux: Call put_page if errors in aops->readpages

Within the address_space_operations readpages function, when we remove a
page from the page->lru list, we must ensure that the page reference
count is decremented via put_page.

There are two cases within the flow of the afs_linux_readpages where
we remove a page from the page->lru list, but fail to put_page() it.

 - If we go through afs_linux_bypass_readpages we fail to call
   put_page() if the page index is larger than the index calculated from
   i_size_read for the cache file.
 - If get_dcache_readahead returns an error in afs_linux_readpages, we
   fail to put_page().  This can happen if there was a problem opening
   the cache file, or if the cache file has no a_ops->readpage.

Add a call to put_page in afs_linux_bypass_readpages when the page index
is greater than the index calculated from the i_size_read for the cache
file.

Add a call to put_page in afs_linux_readpages if get_dcache_readahead
returns an error.

Note: The condition of not calling put_page if there was an error
opening the cache file was introduced by commit 'LINUX: Don't panic on
some file open errors' (af73b9a3b1f), which replaced an assert with
code that handled the error.  The other conditions have existed since
the relevant code was introduced.

In addition, the problems addressed by this commit are not present in
Linux kernels 5.8 and greater when the commit 'Linux-5.18: replace
readpages with readahead' (7a181415db1) is present, because we call
afs_linux_readahead instead of afs_linux_readpages.

Change-Id: Ibabd6519601366d7d944138b1f663fbb6002a879
Reviewed-on: https://gerrit.openafs.org/15068
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

20 months agobuild: package ltmain.sh in the libafs_tree 76/15076/3
Michael Meffie [Mon, 18 Jul 2022 23:17:26 +0000]
build: package ltmain.sh in the libafs_tree

Commit 0a58d2188[1] "cf: Run AFS_LT_INIT after setting CC" moved the
location of LT_INIT (libtool initialization) to a common macro, so it is
now expanded in configure-libafs.  This breaks the linux DKMS packaging,
which uses configure-libafs to build the kernel module, since the
ltmain.sh aux file is not included in the dkms package.

For now, just include the ltmain.sh aux file in the libafs_tree files to
fix DKMS build.  Later, we should restructure the autoconf macros so the
LT_INIT macro is not expanded in the configure-libafs configure script,
since we do not need libtool to build the kernel module.

Thanks to Alex T Prengel for reporting this issue on the openafs-info
mail list.

1) 0a58d21881d7e91deccb416e8d2c272e14b412dd cf: Run AFS_LT_INIT after setting CC

Change-Id: I5aec1711ab33cc619c233889db3f55f83343c4d9
Reviewed-on: https://gerrit.openafs.org/15076
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agoLinux-5.19: Remove flags from aops->write_begin 41/15041/7
Cheyenne Wills [Tue, 5 Jul 2022 16:33:19 +0000]
Linux-5.19: Remove flags from aops->write_begin

The Linux 5.19 commits:

 fs: Remove aop flags parameter from grab_cache_page_write_begin()
  (b7446e7c)
 fs: Remove flags parameter from aops->write_begin (9d6b0cd7)

removed the flags parameter from the address space operations
'write_begin' as well as removing the flags parameter from the Linux
function 'grab_cache_page_write_begin'.

Add an autoconf test to see if grab_cache_page_write_begin takes 2 or
3 parameters. Use this as a test to determine if the address space
operations 'write_begin' takes a flags parameter.

Create a version of afs_linux_write_begin that does not take a flags
parameter, which also calls grab_cache_page_write_begin without flags.

Change-Id: Ib98c615e6964202748c78037c9ecac459fc3372b
Reviewed-on: https://gerrit.openafs.org/15041
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agoLinux-5.19: Rename aops readpage to read_folio 40/15040/7
Cheyenne Wills [Tue, 5 Jul 2022 17:45:29 +0000]
Linux-5.19: Rename aops readpage to read_folio

With Linux commits:
  mm,fs: Remove aops->readpage   (7e0a126519)
  fs: Introduce aops->read_folio (5efe7448a1)

the address space operations method 'readpage' was replaced with
read_folio.  The operation behaves the same, except instead of taking a
struct page parameter, the new function takes a folio structure.

Add an autoconf test for the address space operation entry read_folio

Replace the references to an address space operations' readpage with
read_folio.  Note that the function Linux page_folio can be used to
obtain the required pointer to the folio for a given page.

Introduce afs_linux_read_folio that accepts a folio and calls
afs_linux_readpage with the page associated with that folio.

Change-Id: I2c43a9bfb26042f7cc2c55807d46b33769f2594a
Reviewed-on: https://gerrit.openafs.org/15040
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

21 months agoLinux: Introduce file mapping readpage helpers 39/15039/6
Cheyenne Wills [Tue, 5 Jul 2022 16:28:10 +0000]
Linux: Introduce file mapping readpage helpers

Create a helper function that determines if a file's
 i_mapping->a_ops->readpage
is NULL.

Create a helper function that calls a file's
 i_mapping->a_ops->readpage

There are no functional changes with this commit.

Note: This commit isolates references to 'readpage' so that future
commits can change the name in a more straight forward manner.

Change-Id: If3ad33766c7a3bce27c2aa3c3b409157264230b1
Reviewed-on: https://gerrit.openafs.org/15039
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agoautoconf: Remove redundant exit statements 49/15049/3
Michael Meffie [Mon, 4 Jul 2022 15:04:19 +0000]
autoconf: Remove redundant exit statements

The AC_MSG_ERROR macro prints an error message to the standard error
output and exits configure with exit-status (1 by default), so the
exit statements following AC_MSG_ERROR are never reached.

Change-Id: I7a4e6e4501e55fb49eab8d7773d281a36f868525
Reviewed-on: https://gerrit.openafs.org/15049
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agoautoconf: Remove unused SUBARCH variable 48/15048/3
Michael Meffie [Mon, 4 Jul 2022 14:58:30 +0000]
autoconf: Remove unused SUBARCH variable

The SUBARCH variable was added in the work-in-progress commit
f3cd6ca06315691c46f9a3f917099efaed57fe3d (linux-26-progress-20040412)

The last use of SUBARCH was removed in commit
51799f7cc0337e6ecc7892be7b8700737712b5e5 (linux-try-kbuild-20060804)

Change-Id: I9b28655f5d671850f4adc8b1d0ee015eca9480a6
Reviewed-on: https://gerrit.openafs.org/15048
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agoCODING: Fix a couple of typos 46/15046/2
Andrew Deason [Wed, 29 Jun 2022 22:18:01 +0000]
CODING: Fix a couple of typos

Change-Id: I2792f710a4bc61ea755b5231a9819971754ed808
Reviewed-on: https://gerrit.openafs.org/15046
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agoLinux-5.18: replace readpages with readahead 53/14953/13
Cheyenne Wills [Mon, 27 Jun 2022 14:38:25 +0000]
Linux-5.18: replace readpages with readahead

The linux 5.18 commit 'fs: Remove ->readpages address space
operation' (704528d8) removes the address_space_operations operation
"readpages", which is replaced with the "readahead" operation
that was introduced with the 5.8 commit 'mm: add readahead address
space operation' (8151b4c8).

When readahead is called, the pages in 'rac' have already been added to
the lru caches and are locked. For each page that we get from the 'rac'
(i.e. from 'readahead_page(rac)'), we must unlock and put_page the page;
if we successfully populated the page with data, we also set
PageUpToDate.  If we don't process all the pages in 'rac', the caller
will handle cleaning up any remaining pages; we don't need to unlock/put
them or touch them at all.
  (See Linux Documentation/filesystems/vfs.rst)

Add an autoconf test to detect the presence of 'readahead' in the
address_space_operations structure.

For the implementation of readahead (which is contained in Linux's
osi_vnodeops.c):

Add new functions 'afs_linux_bypass_readahead' and 'afs_linux_readahead'
as replacements for 'afs_bypass_readpages' and 'afs_linux_readpages'
when the linux kernel supports the readahead operation.

Notes:
  In afs_linux_bypass_readahead, the pages are already locked and are
  already in the page cache, we just need to place the page into the
  iovecp.  The page's refcount will be decremented and will be unlocked
  when processing the read request.

  In afs_linux_readahead, the lrupages is needed in case a page is added
  to the cachefp's mapping in afs_linux_read_cache (which also handles
  unlocking the page).

  In afs_linux_readahead, if there is no tdc, we must still unlock the
  page otherwise the read process will wait on that page.

Change-Id: I6960a2fc14df85869c373f3e3afbf3ee5eb7228f
Reviewed-on: https://gerrit.openafs.org/14953
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agoChange klog.krb5 -lifetime option help description 45/15045/2
Michael Meffie [Wed, 29 Jun 2022 14:33:23 +0000]
Change klog.krb5 -lifetime option help description

Change the klog.krb5 -lifetime help description to show this option is
ignored.  This option name was copied from the krb4 command but is not
implemented for the krb5 version. It is retained for command line syntax
compatibility.

Change-Id: I7f4e81609cf3613a7173e2b6f2e6b1bfb8cd4dc8
Reviewed-on: https://gerrit.openafs.org/15045
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agobozo: Let the bnode operations allocate output strings 66/14766/12
Michael Meffie [Tue, 27 Jul 2021 18:35:23 +0000]
bozo: Let the bnode operations allocate output strings

The GetInstanceParm and GetStatus bosserver RPCs return output strings
by first allocating a 256 byte buffer then calling the bnode operations
bnode_GetParm() and bnode_GetString() to fill those buffers.  The RPC
output strings are automatically freed by XDR.

In order to support large output strings in the future, change these
bnode operations to allocate the output strings and to use safe string
functions to duplicate and format strings.

Update the ez, cron, fs, and dafs getstring and getparm operations to
allocate the output string or return an error.

Return BZIO over the wire when a string cannot be allocated, since
ENOMEM is not a portable wire error code.  (Use BZIO to be consistent
existing code added in commit fda2bc874751ca479365dc6389c0eebb41a0bda1
(Allocate pathname buffers dynamically).

Commit ea276e83e3 (OPENAFS-SA-2019-001: Skip server OUT args on
error) is a prerequisite for this change.

Change-Id: Id16184efc95d614846b912177b220c8e87b7a88b
Reviewed-on: https://gerrit.openafs.org/14766
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

21 months agobozo: Check for negative simple bnode parameter index 43/15043/3
Michael Meffie [Wed, 22 Jun 2022 17:31:40 +0000]
bozo: Check for negative simple bnode parameter index

The simple (ez) bnodes have only one parameter, which is accessed as
index 0.  A check is made for values greater than 0, however the index
argument is a signed type, and a check for negative indices is missing.

Explicitly check for non-zero index values when retrieving simple bnode
parameters, and if not zero return BZDOM.

The other bnode types already check for specific (positive) index
values, so only the simple bnode type needs to be updated.

Change-Id: I8764af6c975431caf26c25a371cf6db10e6e7fec
Reviewed-on: https://gerrit.openafs.org/15043
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agoPrevent sscanf format widths from overrunning array 36/13136/11
Cheyenne Wills [Tue, 7 Jun 2022 18:19:44 +0000]
Prevent sscanf format widths from overrunning array

cppcheck noted these instances of sscanf could wipe out the ending null
terminator.  Length is now macro expanded rather than hard coded and the
array itself is one unit longer to avoid the overrun.

Change-Id: Ic76e1b74701d7fb7b722ba1f8eae3a4d16e91f65
Reviewed-on: https://gerrit.openafs.org/13136
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agoopr: replace AFS_STRINGIZE with opr_stringize 29/15029/4
Cheyenne Wills [Tue, 21 Jun 2022 15:50:41 +0000]
opr: replace AFS_STRINGIZE with opr_stringize

To avoid adding new includes for afs/afsutil.h in order to use
'AFS_STRINGIZE', create a replacement, 'opr_stringize', in afs/opr.h.

Replace the usage of 'AFS_STRINGIZE' with opr_stringize and remove the
definition of 'AFS_STRINGIZE'

Change-Id: I6d12ed101b6f9246a59c46024c216c7fe25bc1c8
Reviewed-on: https://gerrit.openafs.org/15029
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agolwp: Ignore dangling-pointer warning in process.c 57/14957/9
Cheyenne Wills [Tue, 7 Jun 2022 17:14:55 +0000]
lwp: Ignore dangling-pointer warning in process.c

In lwp/process.c the address of a stack variable is saved as part of
creating a new context.  GCC-12 is flagging the statement with a
diagnostic:

  ./process.c:46:24: error: storing the address of local variable
      ‘stackvar’ in ‘*savearea.topstack’ [-Werror=dangling-pointer=]
   46 |     savearea->topstack = (char *)&stackvar;
      |     ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~

In this particular case, the code is meaning to save the address of the
stack in preparation of setting up a new context, which requires knowing
the address the current stack.

The diagnostic is changed from a warning to an error when configured
with --enable-checking.

Set the env variable CFLAGS_NODANGLING_POINTER to
'-Wno-dangling-pointer' if the compiler supports the option and update
the src/lwp/Makefile.in to use the flag when compiling process.c

Change-Id: Ibec956b505c0edad9b74d63b9bb7805f6f0cba01
Reviewed-on: https://gerrit.openafs.org/14957
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agoafs: Avoid always-false NULL test on AFSTOV(avc) 56/14956/7
Cheyenne Wills [Tue, 21 Jun 2022 15:57:40 +0000]
afs: Avoid always-false NULL test on AFSTOV(avc)

GCC-12 is flagging a comparison with the following diagnostic:

 src/afs/afs_vcache.c:3161:25: error: the comparison will always
    evaluate as ‘false’ for the address of ‘v’ will never be NULL
    [-Werror=address]
 3161 |             AFSTOV(avc) == NULL || vType(avc) == VDIR ||
      |                         ^~

When the vcache structure does not have the vnode embedded the expansion
of the AFSTOV macro results in:
   ((avc)->v)
which tests contents of a 'v'.

When the vcache structure does have the vnode embedded, the expansion of
the macro results in:
   (&(avc)->v)
which tests the address of 'v', which will never be NULL in this case.

Update afs.h to add a new define 'AFS_VCACHE_EMBEDDED_VNODE' when the
vcache structure contains an embedded vnode structure.  Restructure the
preprocessor statements for the AFSTOV definition

Avoid testing AFSTOV(x) against NULL when AFS_VCACHE_EMBEDDED_VNODE is
defined.

The diagnostic is changed from a warning to an error when configured
with --enable-checking.

Change-Id: Ib72647fa23e5a7ecd96772b04c6ef76540f44535
Reviewed-on: https://gerrit.openafs.org/14956
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agobozo: Return BZDOM when BOZO_EnumerateInstance index is negative 31/15031/3
Michael Meffie [Wed, 8 Jun 2022 13:03:32 +0000]
bozo: Return BZDOM when BOZO_EnumerateInstance index is negative

The BOZO_EnumerateInstance looks up a bnode instance with a zero-based
index (anum) and returns BZDOM when the index is out of range for the
current list of bosserver bnode instances.

The index is defined as a signed integer by the RPC, but the implementation
does not check for a negative index.  Currently, the implementation
returns an empty string when a negative (out of range) index is given.

Instead, return a BZDOM error to indicate the index is out of range.

Commit ea276e83e37e5bd27285a3d639f2158639172786 (OPENAFS-SA-2019-001:
Skip server OUT args on error) is a prerequisite for this change.

Change-Id: I4df5d35aaccdbfcbe8e8dcc4fa1aa45ee06b06ab
Reviewed-on: https://gerrit.openafs.org/15031
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

21 months agobozo: Use BZIO for out of memory errors 30/15030/3
Michael Meffie [Wed, 8 Jun 2022 12:36:10 +0000]
bozo: Use BZIO for out of memory errors

Return a BZ error code over the wire when memory cannot be allocated,
since ENOMEM is not a portable wire error code.

Use BZIO for these errors to be consistent with the existing bosserver
code added in commit fda2bc874751ca479365dc6389c0eebb41a0bda1 (Allocate
pathname buffers dynamically).

The incorrect error codes were added in:

fda2bc874751ca479365dc6389c0eebb41a0bda1 Allocate pathname buffers dynamically
381597851b659f00747b22efc24240073c4403ce bozo: Fix problems found by static analysis

Change-Id: I6e19aba226441159ba9e7d4173d2145f5d6745c2
Reviewed-on: https://gerrit.openafs.org/15030
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

22 months agoafs: introduce get_dcache_readahead 62/14962/8
Cheyenne Wills [Thu, 9 Jun 2022 19:20:02 +0000]
afs: introduce get_dcache_readahead

Relocate the block of code that obtains the dcache for a readahead
operation from the afs_linux_readpages function into its own static
function.

Change-Id: Iaaf9523532e292a1f2426d5ced65ddfbceb5d060
Reviewed-on: https://gerrit.openafs.org/14962
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

22 months agoafs: introduce afs_alloc_ncr/afs_free_ncr 54/14954/8
Cheyenne Wills [Mon, 6 Jun 2022 18:27:43 +0000]
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>

22 months agoafs: Use literal NULL for NULL function pointer 02/14902/4
Cheyenne Wills [Fri, 18 Feb 2022 01:32:41 +0000]
afs: Use literal NULL for NULL function pointer

The clang compiler complains that this function pointer cast is not a
prototype.

   .../osi_file.c:141:27: error: this function declaration is not a
      prototype [-Werror,-Wstrict-prototypes]
    afile->proc = (int (*)())0;
                          ^
                           void

Just use NULL instead of trying to create a cast to 0.

Change-Id: I3adb22cb38db8c854d9313ec9eb2b008a4e9a9db
Reviewed-on: https://gerrit.openafs.org/14902
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

22 months agocf: Avoid nested C functions built by autoconf 01/14901/4
Cheyenne Wills [Fri, 18 Feb 2022 01:27:02 +0000]
cf: Avoid nested C functions built by autoconf

Currently, two of the Linux-related autoconf macros try to compile code
containing nested C functions (AC_CHECK_LINUX_OPERATION and
LINUX_KMEM_CACHE_CREATE_CTOR_TAKES_VOID).  For example, the
AC_CHECK_LINUX_OPERATION check for 'follow_link' generates this code
where 'op' is a nested function inside 'conftest':

   #include <linux/module.h>
   #include <linux/fs.h>
   void conftest(void)
   {
       struct inode_operations ops;
       const char *op(struct dentry *dentry, void **link_date) {
           return (const char *)0;
       };
       ops.follow_link = op;
   }

Nested functions are a gcc-specific feature, and are not supported by
other compilers (e.g. clang), causing these checks to always fail when
using clang, leading to incorrect configure results.

To fix this, change AC_CHECK_LINUX_OPERATION and
LINUX_KMEM_CACHE_CREATE_CTOR_TAKES_VOID macros to just define the
relevant function as a proper top-level function.

(these were discovered by forcing a clang build of both the Linux kernel
and the openafs kernel module)

Change-Id: I1f5410d6702025d228b6ed80e7b86b9745ffe3dc
Reviewed-on: https://gerrit.openafs.org/14901
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

22 months agocf: Use -Werror when checking for -Wno-* flags 00/14900/4
Cheyenne Wills [Tue, 1 Mar 2022 22:35:07 +0000]
cf: Use -Werror when checking for -Wno-* flags

When detecting valid compiler flags clang behaves differently than gcc
for certain types of flags.  Specifically, gcc will ignore an unknown
"-Wno-someflag" while clang will issue a warning.  If using clang and
--enable-checking is specified, this difference causes a build failure
because the warning for the unknown flag is turned into an error.

The autoconf macro AX_APPEND_COMPILE_FLAGS (via the underlying macro
AX_CHECK_COMPILE_FLAGS) looks specifically for errors and not warnings
to determine if the flag is valid.  In order to properly catch the above
type of unknown compiler flags, a '-Werror' must be passed as an
extra-flag.

Update the autoconf functions that use AX_APPEND_COMPILE_FLAGS to use
'-Werror' as an extra flag when testing for "-Wno-..." flags.

Note, for gcc, the test may (incorrectly) think that the compiler
supports the given flag, but that is okay, since the flag will be
ignored by gcc during the build without raising any warnings or errors.

Change-Id: I9e4dabf04a3b019cb1ea58a4b2ac1cf0fc8d1e71
Reviewed-on: https://gerrit.openafs.org/14900
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

22 months agofinale: Use unified_afs.o from objdir 25/15025/2
Andrew Deason [Sat, 4 Jun 2022 23:36:20 +0000]
finale: Use unified_afs.o from objdir

Commit bffc354ff7 (finale: translate_et (Unix) support for UAE) added
a dependency on unified_afs.o, but it uses a srcdir path. For objdir
builds, this will only exist in objdir and not srcdir, so make cannot
find the file and the build fails.

Use an objdir path instead.

Change-Id: Ie581ad9cf587dfccd73bcb41b942ea727a683e1f
Reviewed-on: https://gerrit.openafs.org/15025
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

22 months agoRemove osi_GetTime from param.i386_dfbsd_23.h 92/14992/2
Andrew Deason [Fri, 3 Jun 2022 18:40:53 +0000]
Remove osi_GetTime from param.i386_dfbsd_23.h

Commit a5c3dfe99f (afs: Move osi_GetTime out of param.h) moved all
osi_GetTime definitions from param files into osi_machdep.h for the
given platform. But while it added an osi_GetTime for the DFBSD
osi_machdep.h, it forgot to remove the osi_GetTime definition from the
only DFBSD param file we have, param.i386_dfbsd_23.h.

Get rid of the lingering extra definition.

Change-Id: Ic391922e9fe2551065342b4f9ef3b148402d70b6
Reviewed-on: https://gerrit.openafs.org/14992
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

22 months agoafsd: Avoid fscanf overflows when paring cacheinfo 58/14958/6
Cheyenne Wills [Wed, 11 May 2022 14:48:52 +0000]
afsd: Avoid fscanf overflows when paring cacheinfo

clang-14 is producing the following diagnostic:

    afsd.c:581:44: error: 'fscanf' may overflow; destination buffer in
      argument 3 has size 1024, but the corresponding specifier may
      require size 1025 [-Werror,-Wfortify-source]
        fscanf(cachefd, "%1024[^:]:%1024[^:]:%d", tCacheMountDir,

fscanf is being used to parse the contents of a file and the buffer
sizes are hardcoded.  Simply increase the size of the 2 buffers by 1.

The diagnostic warning is changed to an error when configured with
--enable-checking.

Change-Id: Iefbc4e87242232531a266e876fe779476b42fb62
Reviewed-on: https://gerrit.openafs.org/14958
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

22 months agovol: Use asprintf in _namei_examine_special 55/14955/4
Cheyenne Wills [Wed, 25 May 2022 02:14:36 +0000]
vol: Use asprintf in _namei_examine_special

GCC-12 is flagging an snprintf statement with a format truncation
warning:

  namei_ops.c: In function ‘namei_ListAFSSubDirs’:
  namei_ops.c:2029:22: error: ‘%s’ directive output may be truncated
   writing up to 255 bytes into a region of size between 0 and 511
   [-Werror=format-truncation=]

Change code to use asprintf instead of snprintf.  Return an error if a
memory allocation fails.

Change-Id: I1f617ab22dbec4c2497ec482115cd20c9af0ecfa
Reviewed-on: https://gerrit.openafs.org/14955
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

22 months agoukernel: Fix AFS_GUNLOCK panic in rx_ServerProc 63/14963/2
Cheyenne Wills [Wed, 25 May 2022 18:54:50 +0000]
ukernel: Fix AFS_GUNLOCK panic in rx_ServerProc

At the beginning of UKERNEL's rx_ServerProc a call to AFS_GUNLOCK
panics with 'afs global lock not held'.

The commit 'afs: Drop GLOCK for various Rx calls' (d5e1428a3b) altered
afs_RXCallBackServer so the global lock is released prior to calling
rx_ServerProc, and to reacquire the lock after rx_ServerProc returns.

Remove the AFS_GUNLOCK at the start and the AFS_GLOCK at the end of
UKERNEL's rx_ServerProc.

Change-Id: Id0e2fef574e4d3473e83f77615d194448f55ab47
Reviewed-on: https://gerrit.openafs.org/14963
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

22 months agoafs: Increase NUSERS to 2k 59/14959/3
Andrew Deason [Tue, 3 May 2022 20:57:58 +0000]
afs: Increase NUSERS to 2k

The current value of NUSERS (16) is very small when the client has a
large number of PAGs. When we have a few thousand (or even just a few
hundred), the length of the unixuser hash chains can be come long
enough to cause noticeable differences in performance. Looking up
unixuser structs is a very common code path, since we need to do this
for pretty much any file access that's not already cached at the VFS
layer.

To alleviate this, increase NUSERS to 2k. This is certainly not
necessary on all systems (such as those that never use authentication,
or only have a few PAGs), but the overhead is a very small constant
amount of memory.

Change-Id: I17b32f192656db9ffc97ac47b0923a02803977a3
Reviewed-on: https://gerrit.openafs.org/14959
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

23 months agoDARWIN: On macOS 12, mount afs on user's directory 25/14925/6
Marcio Barbosa [Thu, 7 Apr 2022 22:51:21 +0000]
DARWIN: On macOS 12, mount afs on user's directory

Currently, /afs is mounted/unmounted by a LaunchDaemon. In order to
unmount /afs on restart/shutdown, this daemon runs umount -force /afs.
Unfortunately, SIP (System Integrity Protection) is not allowing the
LaunchDaemon in question to run this command successfully on macOS 12
(exclusively on restart/shutdown):

  umount: Operation not permitted

In this situation, afs can't be turned off correctly, leaving many
unkillable afsd processes lingering around. As a result, the
restart/shutdown process gets stuck indefinitely.

Fortunately, this problem doesn't happen if /afs is mounted on an user's
directory. That said, avoid this issue by mounting /afs on the current
user's directory (/Users/$USER/OpenAFS/afs). Notice that afs is still
accessible (including for other users) through a synthetic link added in
the root directory (/afs -> /Users/$USER/OpenAFS/afs).

Change-Id: Id05d811e785057a82b73d0946154d9be8b5d772a
Reviewed-on: https://gerrit.openafs.org/14925
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

23 months agomacos: Packaging support for MacOS X 12.0 24/14924/6
Marcio Barbosa [Tue, 15 Mar 2022 13:58:16 +0000]
macos: Packaging support for MacOS X 12.0

This commit introduces the new set of changes / files required to
successfully create the dmg installer on OS X 12.0 "Monterey".

Change-Id: I365aecabf12e88bbe7eabd22c8727a5c446656b8
Reviewed-on: https://gerrit.openafs.org/14924
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

23 months agomacos: Add support for MacOS 12.0 23/14923/7
Marcio Barbosa [Thu, 7 Apr 2022 03:16:45 +0000]
macos: Add support for MacOS 12.0

This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on OS X 12.0 "Monterey".

Change-Id: Iada9cab596747122c1973654ae4f78d52957c8a6
Reviewed-on: https://gerrit.openafs.org/14923
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

23 months agoDARWIN: Replace afs_osi_cred by allocated ucred 22/14922/7
Marcio Barbosa [Tue, 15 Mar 2022 13:38:45 +0000]
DARWIN: Replace afs_osi_cred by allocated ucred

Building the current version of OpenAFS on macOS Monterey arm64 results
in the following error:

 error: globals with authenticated null values are currently unsupported
 afs_ucred_t afs_osi_cred;

To avoid this problem, replace the global in question by a pointer to a
dynamically allocated afs_osi_cred (afs_osi_credp). Ideally we would
create a new credential with kauth_cred_create(), but this function is
not well documented and using it results in crashes. Moreover, if the
kauth_cred_dup() function were still available (private since XNU
1456.1.26 - macOS 10.6), we could also duplicate the current user's
credential during startup (like commit f40f466c7f did for BSD).

Change-Id: Ied2df7590e4e671ce2643669c83ee0e4b2a97cd1
Reviewed-on: https://gerrit.openafs.org/14922
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

23 months agomacos: Add support for Apple Silicon 46/14746/11
Marcio Barbosa [Thu, 7 Apr 2022 22:35:02 +0000]
macos: Add support for Apple Silicon

This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on Apple M1 (macOS 11+).

Notice that kexts on Apple silicon must support the arm64e architecture,
since they run in kernel space and must support the same architecture
and restrictions as other kernel code. On the other hand, the utilities
that run on user space, like vos, fs, and others, have to be built for
arm64 (currently).

Change-Id: Ib005215ae9bfb0b9dda94b2e194f05c0ce92fa1e
Reviewed-on: https://gerrit.openafs.org/14746
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Andrew Deason <adeason@sinenomine.net>

23 months agomacos: Refactor param.x86_darwin_200.h 34/14934/6
Marcio Barbosa [Thu, 7 Apr 2022 02:15:57 +0000]
macos: Refactor param.x86_darwin_200.h

In preparation for a future commit, try to make param.x86_darwin_200.h
more readable. Also, rename this file to param.darwin_200.h so code from
other architectures can be included in this header.

Change-Id: I1617e3ca93b7e9a4eee4ba121aa20d993302eb84
Reviewed-on: https://gerrit.openafs.org/14934
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

23 months agobuild: Select param.h in sysname.m4 14/14914/6
Marcio Barbosa [Mon, 14 Feb 2022 23:09:27 +0000]
build: Select param.h in sysname.m4

Currently, the way the file that will be used as param.h is selected
doesn't allow us to choose headers from other architectures, making
cross-compiling difficult. In an effort to facilitate this process,
select the header that will be used as param.h in sysname.m4. By doing
this, we will have more flexibility to select which header should be
used (in future commits).

Change-Id: I5c77e9e061b847e770bf25f454fe891b5ead9429
Reviewed-on: https://gerrit.openafs.org/14914
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

23 months agomacos: Build afscell for supported architectures 45/14745/10
Marcio Barbosa [Wed, 6 Apr 2022 23:36:15 +0000]
macos: Build afscell for supported architectures

Given that i386 is no longer supported, trying to build the current
version of afscell on macOS 11 (Big Sur) results in the following error:

error: The i386 architecture is deprecated. You should update your ARCHS
build setting to remove the i386 architecture.

To fix this problem, build afscell for all architectures listed in
ARCHS_STANDARD.

For the macosx11.0 sdk:

$ xcodebuild -showBuildSettings -scheme afscell -sdk macosx | grep ARCHS

    ARCHS = arm64 x86_64
    ARCHS_STANDARD = arm64 x86_64
    ARCHS_STANDARD_32_64_BIT = arm64 x86_64 i386
    ARCHS_STANDARD_32_BIT = i386
    ARCHS_STANDARD_64_BIT = arm64 x86_64
    ARCHS_STANDARD_INCLUDING_64_BIT = arm64 x86_64
    VALID_ARCHS = arm64 arm64e i386 x86_64

While here, add arm64 to the list of valid architectures.

Change-Id: I37230e49ff5884234b8195bc49ce8b8938580c9e
Reviewed-on: https://gerrit.openafs.org/14745
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

23 months agoDARWIN: Declare/include functions before using them 44/14744/11
Marcio Barbosa [Wed, 23 Mar 2022 20:58:41 +0000]
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>

23 months agobucoord: Introduce ubik_Call_SingleServer_BUDB_* 86/14886/7
Marcio Barbosa [Wed, 23 Mar 2022 20:31:54 +0000]
bucoord: Introduce ubik_Call_SingleServer_BUDB_*

In an effort to avoid the usage of undeclared functions, add wrappers
for ubik_Call_SingleServer() (_BUDB_GetVolumes(), _BUDB_DumpDB()) and
adjust its callers accordingly.

Also, make sure that ubik_Call_SingleServer() uses the same signature as
ubik_Call(). This change helps us to get rid of casting errors.

Change-Id: I431360f7a42a81b1f20005ebaf0c703bab73a963
Reviewed-on: https://gerrit.openafs.org/14886
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>

23 months agoafs: Ensure dirEntry->name has room for entry name 38/14938/5
Marcio Barbosa [Tue, 5 Apr 2022 22:39:56 +0000]
afs: Ensure dirEntry->name has room for entry name

Currently, the afs_dynroot_addDirEnt() function assumes that the caller
has allocated the directory to be large enough to hold the necessary
entry. In order to make sure that memory isn't being accidentally
stomped, use strlcpy to truncate instead of stomping on other memory.
That way, if the caller makes a mistake we don't silently corrupt memory.

We specifically do not assert that there is no truncation or panic if
truncation occurs, since the effect of a truncated entry in the
dynamic AFS root volume is limited and does not justify bringing down
the entire client.

Change-Id: I9c9b0ee6bc32ae7751005dd9b21a75e878e59fe3
Reviewed-on: https://gerrit.openafs.org/14938
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

23 months agoafs: Replace strcpy &co by safer alternatives 43/14743/11
Marcio Barbosa [Wed, 6 Apr 2022 20:59:56 +0000]
afs: Replace strcpy &co by safer alternatives

In addition to being unsafe, these functions (strcpy, strncpy, strcat,
and sprintf) are deprecated on macOS. Replace these functions by safer
alternatives (strlcpy, strlcat, snprintf, and afs_strdup).

Notice that, in order to use afs_strdup(), this commit adds the afs_util
library to the AFSPAGOBJS list. Given that afs_strcasecmp() is also
implemented in afs_util.c, src/crypto/hcrypto/kernel/strcasecmp.c can be
removed from the tree.

No functional change should be incurred by this commit.

This commit is a continuation of a patch initially developed by
cwills@sinenomine.net.

Change-Id: Id11d8bca133e44f96913f7959d87bc82dbebce29
Reviewed-on: https://gerrit.openafs.org/14743
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>

23 months agoUKERNEL: Remove flock -> usr_flock redirection 13/14913/6
Marcio Barbosa [Wed, 23 Mar 2022 19:04:46 +0000]
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>

23 months agoafs: Remove redundant AFS_LINUX_ENV test 35/14935/4
Andrew Deason [Thu, 24 Mar 2022 17:04:13 +0000]
afs: Remove redundant AFS_LINUX_ENV test

After our Linux checks were converted to AFS_LINUX_ENV in commit
6329a523 (Change AFS*_LINUXnn_ENV to AFS*_LINUX_ENV), the extra
AFS_LINUX_ENV check in this line doesn't make any sense. Get rid of
it.

Change-Id: I4196744b1a6674469efef04aa487a50743084656
Reviewed-on: https://gerrit.openafs.org/14935
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

23 months agoafs: Save size of sysname_info->name 12/14912/4
Marcio Barbosa [Wed, 23 Mar 2022 18:10:15 +0000]
afs: Save size of sysname_info->name

In preparation for a future commit, save the size of sysname_info->name
by adding a new field (name_size) into the sysname_info struct. Also,
remove the sysname_info->allocked field, since now we can find out if
memory has been allocated by checking if sysname_info->name_size is
different than zero.

No functional change should be incurred by this commit.

Change-Id: Id0f5a646b2d82fda5344d53c9fc8b3407f2ea805
Reviewed-on: https://gerrit.openafs.org/14912
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

23 months agocmdebug: Print AFSFid fields as unsigned integers 50/14950/2
Marcio Barbosa [Wed, 20 Apr 2022 13:06:17 +0000]
cmdebug: Print AFSFid fields as unsigned integers

Currently, AFSFid fields are printed as signed integers. As a result,
large numbers can be erroneously printed as negative numbers.

To fix this problem, print AFSFid fields as unsigned integers.

Change-Id: Ic8c39bc90303e35bd982f6a850330d623047e0ec
Reviewed-on: https://gerrit.openafs.org/14950
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoDARWIN: Drop afs_event lock before destroying it 33/14933/2
Marcio Barbosa [Mon, 21 Mar 2022 17:43:34 +0000]
DARWIN: Drop afs_event lock before destroying it

On macOS arm64, a lock (lck_mtx_t) must be released (lck_mtx_unlock)
before it can be destroyed/freed (lck_mtx_free -> lck_mtx_destroy). If
this rules isn't respected, the operating system in question will panic
with the following message:

  panic("lck_mtx_assert(): mutex (%p) not owned", lock);

Unfortunately, the current shutdown process of the osi_sleep module
doesn't respect this rule. As a result, macOS arm64 panics when the
OpenAFS client is shut down/restarted. To fix this problem, release
afs_event->lck (EVTLOCK_UNLOCK) before destroying it (EVTLOCK_DESTROY).

Change-Id: Ifd39fd99c237c783ed98079573fd4043ebab363b
Reviewed-on: https://gerrit.openafs.org/14933
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Avoid plain printf in auth/superuser-t 66/14866/3
Andrew Deason [Tue, 23 Nov 2021 21:56:49 +0000]
tests: Avoid plain printf in auth/superuser-t

If we're reporting an error, we should be printing to stderr. If we're
printing informational data, we should be using diag() to try to avoid
interfering with the TAP data. Change all printf() calls into one of
those two options.

Change-Id: I2e0d577e0c32efa539ed486190dbaca23bd0487f
Reviewed-on: https://gerrit.openafs.org/14866
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Improve fork/waitpid error handling 65/14865/3
Andrew Deason [Tue, 23 Nov 2021 21:52:23 +0000]
tests: Improve fork/waitpid error handling

A couple of places in our test code aren't handling errors from fork()
or waitpid() properly. We don't expect to ever hit errors for these,
but sysbail() in this case, so they don't fail silently.

Change-Id: I1c548f93f4d4ac4344032d7847470b04319386f2
Reviewed-on: https://gerrit.openafs.org/14865
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Put tmp dirs in objdir, not /tmp 64/14864/3
Andrew Deason [Tue, 23 Nov 2021 21:31:33 +0000]
tests: Put tmp dirs in objdir, not /tmp

Currently, all tests that use afstest_mkdtemp() generate a temporary
dir in /tmp, which is removed when the test is done (unless MAKECHECK
isn't set, or the test prematurely exits/crashes). The /tmp dir on a
system may not be the best choice; it may be limited in size, and it's
visible to other users, which is annoying if we are littering the dir
with afs_XXXXXX dirs if broken tests are running during development.

Instead, use a tmp dir in the objdir of the current build
(specifically, tests/tmp/). Since this is the same dir we're building
the tree in, we must be able to write to it and it should have plenty
of space. And it will almost certainly get cleaned up eventually, even
with broken tests, since it will get removed when the build tree is
inevitably removed.

While we're doing this, run the paths from afstest_src_path and
afstest_obj_path through realpath(), so our tmp paths (and other
paths) look a little cleaner, and don't look like
/home/user/openafs/tests/../tests/tmp/foo.

Change-Id: I6633f58ac1f6ef34e33b51cc19d3bff7a4f3fdb0
Reviewed-on: https://gerrit.openafs.org/14864
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>