Russ Allbery [Thu, 27 May 2010 03:04:48 +0000 (22:04 -0500)]
Fix compilation of the imported config_file.c parser
Include additional missing header files for proper function prototypes,
define TRUE and FALSE, and declare krb5_clear_error_message as unused
so that the config_file.c will compile and pass --enable-checking.
Marc Dionne [Wed, 26 May 2010 21:50:43 +0000 (17:50 -0400)]
scout.c: only declare width once
The width variable was declared twice, for the whole function
and also within the for loop, leaving the first one unused
and triggering a warning and a failed build with enable-checking.
Andrew Deason [Wed, 31 Mar 2010 16:40:42 +0000 (11:40 -0500)]
Protect ubik cache accesses
Currently, ubik application cached data could be updated and read by
different threads simultaneously. Add a mechanism in ubik for
protecting accessing and updating the cached data. This adds the
function ubik_CheckCache to do this, and removes ubik_CacheUpdate as
an exported function (since it's not safe).
Update all callers to use the new mechanism. In ptserver, remove the
'initd' variable; just rely on cachedVersion and ubik_CheckCache to
tell us when to re-read the database. Remove db.lock in buserver and
cheader_lock in kaserver, which served similar (though not completely
threadsafe) protection as ubik_CheckCache. Add the ubik database lock
cache_lock to protect the application cache.
Russ Allbery [Wed, 26 May 2010 17:20:57 +0000 (12:20 -0500)]
Remove references to IBM AFS
Change references to the documentation sets that we still ship to
reference the OpenAFS manuals instead of the IBM AFS manuals. Remove
references to the IBM AFS/DFS Migration documentation, since that
doesn't appear to be available anywhere any more, replacing them where
relevant to more generic references to the DFS documentation. Add
links to docs.openafs.org for mentions of the manuals in SEE ALSO, and
standardize on one link format. Replace a few references to the IBM
AFS Release Notes with the actual information in those notes, or drop
the reference if it doesn't seem particularly useful.
Russ Allbery [Wed, 26 May 2010 16:33:29 +0000 (11:33 -0500)]
Remove references to AFS Product Support in -oktozap
salvager and salvageserver's documentation of -oktozap says to not use
without consultation with AFS Development or Product Support, left over
from the IBM product. Remove those references and add a caution more
in line with open source.
Russ Allbery [Wed, 26 May 2010 16:28:57 +0000 (11:28 -0500)]
Remove -rebuildDB flag to ptserver
The -rebuildDB flag was documented to rebuild the Protection Database at
startup, but it was accepted and ignored in the ptserver source, doing
nothing. Remove the documentation and the option recognition in ptserver.
Russ Allbery [Wed, 26 May 2010 16:25:39 +0000 (11:25 -0500)]
Remove documentation of kaserver -fastKeys
-fastKeys wasn't accepted by the kaserver binary, but was still
mentioned in the usage message and the kaserver man page. Remove
the remnants of the flag.
Simon Wilkinson [Tue, 27 Apr 2010 21:53:47 +0000 (22:53 +0100)]
Add an OpenAFS config file parser
This adds a Kerberos INI style config file parser to OpenAFS, using
the parser contained in Heimdal as a base. Currently, it only exports
a very small number of functions, but exporting further functions is
simply a matter of adding additional shims to hide the Kerberos
context and other specifics.
Note that we don't want to just use the parser as a library because
firstly, we don't want OpenAFS to have a Kerberos dependency (as
other crypto mechanisms will, and do, exist). Secondly, MIT and
Heimdal use a different API here, so we would have to shim anyway.
Also, our own parser means that we don't need to worry about passing
in the krb5 context, and all of the issues that that presents.
Russ Allbery [Tue, 25 May 2010 19:37:05 +0000 (14:37 -0500)]
Synchronize LICENSE files
We have two LICENSE files, which had been somewhat independently
modified. Resynchronize them, remove trailing whitespace, and convert
from ISO 8859-1 to UTF-8.
Simon Wilkinson [Thu, 20 May 2010 10:57:20 +0000 (11:57 +0100)]
Linux: Disable syscall probes if we have keyrings
If we are building for are kernel with keyrings, and we can
guarantee that we can make use of those keyrings, then we no longer
need to probe for the syscall table at all. Change our default
behaviour so that when these two conditions are true, syscall probing
is disabled. Both --enable-linux-syscall-probing and
--disable-linux-syscall-probing can be used to override the
autodetection and force things one way or the other.
We have to check that we can use the keyrings because there was a
window in the 2.6 kernel series where keryings were available, but
the key_type_keyring definiton (which we use to create the session
keyring) wasn't exported. In that situation, we attempt to traverse
the process table and use the type of init's session keyring. This
traversal is fragile, and if it fails, keyring PAGs will be disabled.
So, we still want to be able to fall back to patching the syscall
table, if we can, in this case.
Russ Allbery [Tue, 25 May 2010 03:03:49 +0000 (22:03 -0500)]
Fix libafs_tree's cross-architecture support
The results of libafs_tree are supposed to build on any platform that
shares the same basic kernel code, but this had broken in two ways:
libafs_tree was including a pre-built afs/param.h, which needs to be
regenerated on different architectures, and the Linux kernel build
makefile was being pre-generated despite having some architecture-specific
options.
Copy over more of src/config and postpone generation of afs/param.h and
generation of libafs/Makefile to the libafs build.
Remove the substitution of AFS_SYSNAME from make_libafs_tree.pl; it was
unused and now definitely shouldn't be used since it will break the
architecture-independence of the resulting tree.
Russ Allbery [Tue, 25 May 2010 02:34:53 +0000 (21:34 -0500)]
Postmoderize use of AC_CHECK_TYPE
Use AC_TYPE_SSIZE_T to handle the ssize_t check (introduced in Autconf
2.60). Use AC_CHECK_TYPE, not AC_CHECK_TYPES, to check for sig_atomic_t
and socklen_t, and define them in afsconfig.h if they're not present on
this platform. Do not define them in stds.h, since stds.h is an installed
header file and cannot rely on Autoconf defines.
Russ Allbery [Mon, 24 May 2010 19:28:01 +0000 (14:28 -0500)]
Update fs {get,set}serverprefs documentation for DNS
Mention in the fs getserverprefs and fs setserverprefs documentation
that VL servers may also come from DNS AFSDB and SRV records. Document
that SRV record information is not (yet) properly used.
Rod Widdowson [Tue, 18 May 2010 13:48:38 +0000 (14:48 +0100)]
Read volume at correct address when looking for broken forward links.
vldb_check was reading a volume at the index rather than the file
offset to read the volume. This was giving rise to phantom warnings
since the hash was usually 0.
The possibility of a broken flink is determined in another manner
which is why in normal case we are not flooded with warnings.
At the same time make the error message slightly more coherent.
Simon Wilkinson [Sat, 22 May 2010 08:40:05 +0000 (09:40 +0100)]
Autoconf: Tidy up resolver retrans retry test
There's no need for the retrans retry test to be a TRY_RUN test,
TRY_COMPILE will pick up the existence of the '_res' structure and
its elements.
Also, clean up the use of the cache variable to set the result. In
the old implementation a true test result would print '1', not 'yes',
a false result would result in bad output in the config.log, and a
cross compiling output would give
#define HAVE_RES_RETRANSRETRY no
which will give unexpected results with #ifdef tests.
Russ Allbery [Mon, 10 May 2010 00:58:33 +0000 (17:58 -0700)]
Update bos addkey/listkeys and KeyFile man pages for asetkey
Clearly prefer asetkey to bos addkey in the KeyFile, bos addkey, and
bos listkeys man pages. Reference asetkey list and asetkey delete as
alternatives to bos listkeys and bos removekey. Distinguish between
Authentication Server cells and Kerberos v5 cells and mention the
preferred afs/<cell> principal format. Add some cautions around
matching enctypes and salts when synchronizing keys with a v5 KDC.
Update man-pages/README for completion of this task, clean up some
other wording, and remove some other now-irrelevant information.
Simon Wilkinson [Wed, 19 May 2010 17:11:58 +0000 (18:11 +0100)]
Linux: Use positional r/w, not llseek
The Linux read/write file operations take a position. Use this
position to determine where we're reading or writing in a file,
rather than using the vfs_llseek() operator to set the file
position argument. This avoids a potential race condition, as
well as simplifying this code.
Change-Id: I82b4a109f9871fa2ce5b308bc32923b1bf910920
Reviewed-on: http://gerrit.openafs.org/1993 Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com> Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
Simon Wilkinson [Thu, 29 Apr 2010 18:06:37 +0000 (19:06 +0100)]
Unix CM: Use macros for process name and id access
This patch uses the new osi_procname() macro to obtain the process
name for setpag() warnings on BSD and Darwin, and osi_curproc() to
obtain the process identity, simplifying the code.
Change-Id: I1f8a4d4bbcdb09eaeea3712b1fffd1aaa3cd2fa7
Reviewed-on: http://gerrit.openafs.org/1878 Reviewed-by: Derrick Brashear <shadow@dementia.org> Reviewed-by: Matt Benjamin <matt@linuxbox.com> Tested-by: Derrick Brashear <shadow@dementia.org>
Ben Kaduk [Wed, 19 May 2010 05:44:44 +0000 (01:44 -0400)]
Do not sleep in FBSD's getevent()
Calling osi_AllocSmallSpace drops the glock, which allows
a race condition that caused a rather fast deadlock on
multiprocessor systems.
Use afs_osi_Alloc_NoSleep instead.
Define the PageCheck family of functions using PageFsMisc
equivalents if those are found. I encountered a need for this
on Centos 5.5 (2.6.18-8.el5xen), but it may be more general.
Simon Wilkinson [Mon, 17 May 2010 19:15:46 +0000 (20:15 +0100)]
Fileserver: Don't sync every 10 seconds
The patch which moved our calls to fsync into the background, added
a sync prior to each batch of fsync calls. This is an incredibly bad
idea.
POSIX says that sync "shall cause all information in memory that
updates file systems to be scheduled for writing out to all file
systems". On Linux this means that we in effect perform an fsync()
on every open filehandle on the entire system, and in addition flush
all superblocks and journals out to disk. This makes the following
fsync() calls superfluous - sync() will have already written out
all of the data.
Add to this the fact that the fileserver is doing this every 10
seconds, and this becomes a major performance bottleneck,
particularly if the machine uses a journalled fs - as any disk
operations will end up blocking whilst the journal is written to
disk.
Jeffrey Altman [Mon, 17 May 2010 20:01:03 +0000 (16:01 -0400)]
rx: work harder to notice and handle MorePackets request
in particular, we did badly at handling kernel requests for
more packets, but other cases did not properly keep packet
stats either. attempt to globally better handle demand for
more packets.
Simon Wilkinson [Mon, 17 May 2010 07:40:49 +0000 (08:40 +0100)]
Autoconf: Use AC_CACHE_CHECK
AC_CACHE_CHECK has been available since Autoconf 2.5 (released in
1995), and provides a simpler mecahnism for performing cached checks
than AC_CACHE_VAL does. Modify all of our simple AC_CACHE_VAL calls
to use AC_CACHE_CHECK.
Rod Widdowson [Wed, 12 May 2010 14:48:25 +0000 (15:48 +0100)]
Clean up logging from vldb_check.
vldb_check used to say "%<index>: Volume '<name>' <id>not found in <type> hash <hash>" for two sorts of failures
- If the volume really wasn't in a hash chain of that type at all
- If volume's next pointer (for the hash type) pointed to a volume with a different hash.
In both cases it would then print out some confusing (and spurious)
information about the next element in the chain, prior to applying the
same fix (of zeroing the next pointer).
Rod Widdowson [Sat, 15 May 2010 15:25:26 +0000 (16:25 +0100)]
Stop overanxious htonl in vldb_check -fix
vldb_check -fix is corrupting the server entries (Number, Partition,
Flags). This is because it is doing a htonl on what is a char field.
The read code already has a comment "make sure not to ntohl these,
as they're chars, not ints".
This change strips the corresponding htonl from writeheader (and puts
in a similar comment).
Simon Wilkinson [Sun, 25 Apr 2010 19:23:27 +0000 (20:23 +0100)]
Demand Attach: Simplify __VVGC_entry_cl_add
The __VVGC_entry_cl_add was giving an uninitialised variable warning
for empty_idx, because it was using a separate variable, empty_found
as a sentinel for when empty_idx was holding a real value. Simplify all
of this by removing the sentinel, and making empty_idx being -1 mean
'not found', and a real value imply found.
Change-Id: I6c485993df1ff8dfd27824234c811af998ff94fa
Reviewed-on: http://gerrit.openafs.org/1833 Reviewed-by: Tom Keiser <tkeiser@sinenomine.net> Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
#ifdef A
if (foo) {
...
} else
#endif
#ifdef B
if (bar) {
...
}
#endif
something_else()
In a situation where we have A && !B, then something_else() ends up
only being run when foo is false. Given that something_else() is
VOL_LOCK, this will not end well.
In the real world, we hit this problen when we build the volume
package with SALVSYNC_BUILD_CLIENT and !FSYNC_BUILD_CLIENT - in
other words, whilst building the fileserver.
Ben Kaduk [Mon, 17 May 2010 04:22:32 +0000 (00:22 -0400)]
Enable PutVCache for FBSD80 and higher
Matt's patches in a123bd8ccd brought in support for FBSD 7.0, but
also disabled several calls to afs_PutVCache() for FBSD80 and
higher. Matt says that that patch was focused on 7.0, so the
8.0-related bits may not be relevant.
I have run with the PutVCache calls enabled, and if anything,
my system seems more stable with them.
Ben Kaduk [Sun, 16 May 2010 04:43:35 +0000 (00:43 -0400)]
Kill FBSD4X with fire
We haven't even pretended to work on the 4.X series for quite some
time, and keeping this code around just makes things (slightly)
harder to read.
AFS_FBSD_ENV is now equivalent to AFS_FBSD50_ENV (though the
latter should not be used).
Leave the fbsd_4 sysnames in afs_sysnames.h for archival purposes.
Simon Wilkinson [Sun, 16 May 2010 22:14:11 +0000 (23:14 +0100)]
Autoconf: Use AC_CHECK_MEMBERS
AC_CHECK_MEMBERS has been available since autoconf 2.50,
which was released in 2001. Use this, rather than rolling our
own mechanism to check for structure membership.
Simon Wilkinson [Sun, 16 May 2010 21:56:13 +0000 (22:56 +0100)]
Autoconf: Use a standard test for socklen_t
Use the standard AC_CHECK_TYPES mechanism to check for the existence
of socklen_t, and to typedef it as an int if it's not found, rather
than growing our own.
Andrew Deason [Sun, 16 May 2010 04:12:33 +0000 (23:12 -0500)]
Solaris: do not call VFS_RELE with GLOCK
VFS_RELE can call afs_freevfs, which grabs GLOCK. Thus, don't call
VFS_RELE with GLOCK held or we can try to recursively acquire GLOCK
and panic. This is currently unlikely to occur (sans vfs refcount
unbalances) without support for forced unmounts, since the last vfs
ref will usually come from the caller of afs_unmount(). But it still
may be possible.
Andrew Deason [Wed, 12 May 2010 18:59:06 +0000 (13:59 -0500)]
Solaris: stop NetIfPoller on shutdown
The NetIfPoller code that is enabled on AFS_SUN510_ENV never gets
shutdown properly. The current code looks as if it was intended for
NetIfPoller to recognize the appropriate termState and just return,
but we never wait for it, and so we can complete the shutdown sequence
without NetIfPoller ever knowing that we are shutting down. This can
cause the machine to panic, as we keep attempting to run NetIfPoller
even after libafs has been unloaded.
Since NetIfPoller is fired by default every 30 seconds, we probably do
not want to wait for it to fire during shutdown. Instead, just destroy
the necessary timeout and task queue, which will wait for NetIfPoller
to complete if running, and will just prevent it from running in the
future otherwise.
Jeffrey Altman [Wed, 12 May 2010 15:27:17 +0000 (11:27 -0400)]
Windows: move afsconfig.h / param.h to afscred.h
move the inclusion of afsconfig.h and param.h to
afscred.h so that they are included everywhere
and so that the conditional use of _USE_32BIT_TIME_T
is applied consistently by afscred.h.
Jeffrey Altman [Sun, 9 May 2010 01:38:05 +0000 (21:38 -0400)]
Rx: prevent rx_rpc_stats mutex from being a global bottleneck
Prior to this patchset, the 'rx_rpc_stats' mutex was superior
to both the 'peer->peer_lock' and the 'rx_peerHashTable_lock'.
That meant that the 'rx_rpc_stats' was being held across many
operations that walk the peer hash table. For example,
rxi_ReapConnections, rx_disablePeerRPCStats, and rx_shutdown.
Since every RPC issues a call to rx_IncrementTimeAndCount, the
reap connections event would effectively bring all RPC processing
to a halt.
This patchset moves 'rx_rpc_stats' later in the hierarchy and
restructures rxi_ReapConnections, rx_disablePeerRPCStats, and
rx_shutdown so that not only doesn't the 'rx_rpc_stats' mutex
need to be held across the entire function but the
'rx_peerHashTable_lock' does not need to be held while complex
operations on the peer object are taking place.
rxi_ReceiveDebugPacket is also fixed to hold the rx_peerHashTable_lock
and peer_lock at appropriate times while completing its function.
Jeffrey Altman [Mon, 10 May 2010 13:07:50 +0000 (09:07 -0400)]
Windows: Prevent overflow during percent used calc in Explorer Shell Ext
In the Volume Info and Partition Info dialog boxes, percent used
was overflowing the variable due to using too small a variable
and multiplying before dividing.
Jeffrey Altman [Mon, 10 May 2010 00:49:05 +0000 (20:49 -0400)]
Windows: use system CreateUuid instead of afs variant
The afs_create_uuid function on Windows results in
duplicate uuids being produced. Windows provides its own
CreateUuid function. Use it when afs_create_uuid is called.
Jeffrey Altman [Sun, 9 May 2010 14:15:30 +0000 (10:15 -0400)]
Make afsio be useful on Windows and fix bugs
On Windows, the stdin and stdout handles default to text
mode which corrupts data piped through them. At the start
of readFile and writeFile, the mode is now set to binary.
The ProbeUuid callback is supposed to determine if this
client is the same as the one being requested. Since we
are advertising a new uuid in TellMeAboutYourself and
WhoAmI, we should perform the uuid check and return a
valid answer in order to avoid confusing the file server.
Add support for TellMeAboutYourself. On Windows, return
valid interface information.
Always print verbose output to stderr.
Display MB/sec to three decimal places.
In readFile, always perform a AFSFetchStatus operation
otherwise we have no idea what the file size is.
Jeffrey Altman [Thu, 6 May 2010 21:12:48 +0000 (17:12 -0400)]
Windows: RXAFS_InlineBulkStat errors must be processed via cm_Analyze
RXAFS_InlineBulkStatus does not return errors such as EACCES,
VNOVOL, VNOVNODE, VOFFLINE, VBUSY, VIO, VMOVED, etc. as an RPC return
code. Instead they are returned in the status info errorCode field
for each file.
Traditionally, the error associated with the first FID in the query
list has been returned to the caller of cm_TryBulkStatRPC().
However, the error has never been processed through cm_Analyze()
which means that the per-vnode processing for VNOVNODE and the volume
global processing for VMOVED, VNOVOL, etc. has never been performed.
As a result, failover to other .readonly volume instances cannot occur,
volume moves will not be handled, and files that have been deleted
are not detected.
This patchset makes the following changes:
1. If an inline bulk operation has been performed and the inline
errorCode is a volume global error, then that error replaces
the RPC return code within the cm_Analyze() processing for
the RPC. This will affect whether or not a retry operation
is performed.
2. The variable 'inlinebulk' is reset to 0 at the top of the
cm_Analyze() loop in case failover from an inlinebulk capable
file to an inlinebulk incapable file server takes place.
3. The FID that is passed into cm_Analyze() is not a real fid.
Instead it consists of the cell and volume but vnode = 0.
This ensures that the error (if any) is not applied to the
directory object.
4. If an inline bulk operation was performed, prior to performing
the cm_MergeStatus() operation a vnode a check is made to
determine if an error was returned for that vnode. If so,
cm_Analyze() is called with no connection, a fake cm_req_t,
the fid, and the error. This permits cm_Analyze() processing
to be performed on the file.
Michael Meffie [Tue, 11 May 2010 19:54:53 +0000 (15:54 -0400)]
Linux: missing configure test
Add the kmem_cache_create test for dtor to the configure to
build again on older versions of linux. Fixes,
osi_vfsops.c:264: error: too few arguments to function
‘kmem_cache_create’
Simon Wilkinson [Thu, 6 May 2010 21:22:50 +0000 (22:22 +0100)]
Remove intptr.m4
We now require an autoconf version of at least 2.60. This version
supplies AC_TYPE_INTPTR_T and AC_TYPE_UINTPTR_T, so we no longer
need to have our own.
Andrew Deason [Wed, 5 May 2010 18:51:23 +0000 (13:51 -0500)]
vlserver: prevent duplicate IPs via ChangeAddr
Add a safety check in VL_ChangeAddr/ChangeIPAddr to check if we are
adding a duplicate server IP in the database. Return VL_MULTIPADDR
when we try to do that.
Jeffrey Altman [Mon, 10 May 2010 00:46:11 +0000 (20:46 -0400)]
Windows: define HAVE_SSIZE_T
The windows param.*.h files define the ssize_t type.
Therefore, we must define HAVE_SSIZE_T in order to avoid
a collision with the ssize_t typedef in afs/stds.h.
Simon Wilkinson [Sun, 9 May 2010 18:40:58 +0000 (19:40 +0100)]
Add a list of files to import from Heimdal
Add an initial list of files to import into OpenAFS from Heimdal.
Currently this is just the list that are required to support
our new configuration file parser.
Simon Wilkinson [Sun, 9 May 2010 18:37:52 +0000 (19:37 +0100)]
Add a tool to import external repositories
This commit adds a tool to aid with the importing of external git
repositories. import-external-git.pl allows a developer to easily
update the src/external portion of the tree to the latest release
of externally developed software. It's currently intended to support
our use of Heimdal functions, but could be extended to support any
project whose code we wish to use in the kernel, and which has a
git repo.
Russ Allbery [Thu, 6 May 2010 19:30:23 +0000 (12:30 -0700)]
Include common param file for Linux alpha builds
The sysname for Linux Alpha is alpha_linux_26 (or 24 or 22) with an
extra underscore before the version, unlike all the other Linux sysnames.
Allow for that case when deciding whether to include the common Linux
param header.
Simon Wilkinson [Thu, 6 May 2010 14:00:00 +0000 (15:00 +0100)]
Modernise use of AC_CHECK_TYPE
Prior to autoconf 2.13, AC_CHECK_TYPE took two arguments, the type
to check and the a default type to use if that type wasn't defined.
This usage has been deprecated since 2.13, and the AC_CHECK_TYPE
macro itself now behaves differently. Whilst there is a compatibility
mode, the autoconf documentation discourages its use.
We also have an occurence of a slightly more modern AC_CHECK_TYPE,
where we explicitly #define a default value if one isn't provided.
The autoconf manual also discourages this form, however, in favour
of using AC_CHECK_TYPES, and placing suitable typedefs in an
external header file.
Modify our code so we do things in the recommended way.
Simon Wilkinson [Thu, 6 May 2010 13:58:52 +0000 (14:58 +0100)]
Always include afsconfig.h in autogenerated files
Modify rxgen and compile_et so that the files they output always
contain afsconfig.h before afs/param.h. This avoids problems where
afs/param.h, or headers included from it, rely on having the results
of configure tests available.
OpenBSD: Use osi_obsd_Free() for all releases of OBSD
Use osi_obsd_Free() in afs_osi_Free() for all releases of OpenBSD,
not just releases from 4.4 onward. Otherwise, afs_osi_Free() will
use AFS_KFREE, which does not exist, since OBSD/osi_machdep.h is
not included, resulting in unresolved symbols when trying to load
the kernel module.
In OpenBSD releases prior to 4.2, use the system (kernel-specific)
FREE macro to release space in the kernel module, not KFREE. The
latter does not exist and results in unresolved symbols when trying
to load the kernel module. (This was undoubtedly a typo.)
Simon Wilkinson [Thu, 6 May 2010 13:55:59 +0000 (14:55 +0100)]
Always include afsconfig.h
Our coding standards say that OpenAFS source files should always have
#include <afsconfig.h>
#include <afs/param.h>
at the start of the file. Including just param.h, or having these
includes in a different order can produce unexpected effects, because
param.h includes sysnames.h, which in turn includes stds.h, which may
rely upon having the results of configure tests available.
Fix the obvious places in the Unix build which get this wrong.
Windows: Secure C String usage in src\WINNT\afsd\fs.c
The use of strlen, strcat, strcpy, strncpy and sprintf in
src\WINNT\afsd\fs.c does not effectively protect against buffer
overruns and string truncation errors. This patchset replaces
their use with StringCbLen, StringCbCat, StringCbCopy,
StringCbCopyN, StringCbCopyEx and StringCbPrintf respectively from
strsafe.h.
The functions sscanf, fscanf and scanf do not check for the size of
the parameters so it is prone to buffer overruns. These functions
can be replaced by sscanf_s, fscanf_s, scanf_s when the Visual Studio
compiler version is 1400 or greater. Also memcpy will be replaced
by memcpy_s which will check for the size of the destination buffer.
In all cases, failure conditions are handled.
Patchset development was mentored by Asanka Herath and Jeffrey Altman.
Change-Id: I01e9dfc616641c220b57d2871e3e140406df3653
Reviewed-on: http://gerrit.openafs.org/1736 Tested-by: Jeffrey Altman <jaltman@openafs.org> Reviewed-by: Tharidu Fernando <tharidufernando@gmail.com> Tested-by: Tharidu Fernando <tharidufernando@gmail.com> Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Andrew Deason [Mon, 3 May 2010 19:57:28 +0000 (14:57 -0500)]
Solaris: shutdown in freevfs, not unmount
Call the afs shutdown sequence (afs_shutdown()) in the VFS_FREEVFS
handler, instead of in the VFS_UNMOUNT handler. This way we shutdown
when the last reference to our vfs goes away, instead of when we are
unmounted. That doesn't make much of a difference right now, but doing
so will be required for supporting forced unmounts.
Andrew Deason [Thu, 29 Apr 2010 22:47:15 +0000 (17:47 -0500)]
Solaris: prevent AFS umount while busy
Return EBUSY from unmount if someone still references stuff in AFS.
This prevents kernel panics that can occur on shutdown if we umount
while there is a file in AFS open. Normally a process can hold a file
in AFS open, AFS is unmounted, and the file is closed, triggering our
code which explodes if called after we're unmounted.
This adds VFS_HOLD/VFS_RELE calls whenever we 'create' a vcache, or
retire an old one, to keep track if anyone has an open reference to
us.
Simon Wilkinson [Sat, 7 Nov 2009 00:16:28 +0000 (00:16 +0000)]
Refactor afs_NewVCache
afs_NewVCache was a twisty turny maze of #ifdefs and duplicated code.
This makes a number of sweeping changes to simplify this code, and to
move platform specific elements out into their own directories.
*) ShakeLooseVCaches is refactored so that the same code can be used
both for platforms that support dynamic vcaches, and those which
don't.
*) afs_NewVCache, ShakeLooseVCaches, and afs_AllocVCache are all
modified to remove platform specific code, and to call platform
specific functions.
*) A new platform file 'osi_vcache.c' is created to hold a number of
platform specific vcache operations:
*) osi_TryEvictVCache handles the decision of whether a vcache can
be evicted or not, and does so if required
*) osi_NewVnode allocates a new vnode
*) osi_PrePopulateVCache does the necessary population of the
vcache, before it's threaded onto the VLRUQ and associated hash
tables.
*) osi_AttachVnode handles attaching an OS vnode to our vcache,
where that is necessary
*) osi_PostPopulateVCache handles the vcache population that must
occur after we're on the VLRUQ and have a vnode attached.
OpenBSD: Fix bug in setpag() when group list is empty
In OpenBSD, the PAG uses the 2nd and 3rd group slots in the task's
group list. If an application sets en empty group list (such as Samba
does), any existing PAG is lost and any new one is NOT set because
the existing code will set the new group count to 2 instead of 3, and
it leaves the first group entry as garbage (whatever random value the
memory contained), thereby totally messing up the task's group list.
This patch fixes it so that it behaves as expected.
Fix pattern to detect i386-based OpenBSD system type
When the pattern to detect OpenBSD system types (via MKAFS_OSTYPE) was split
into two separate ones for amd64 and i386 architectures, the pattern for
i386-based systems was not set quite right. As a result, i386-based OpenBSD
systems are no longer detected properly at this stage, resulting in an error
of "cannot find input file: src/libafs/MakefileProto..in" during configure.
This patch corrects the pattern.