These functions wrap rados_mon_command_target and allow the user to send
"command JSON" to specific MONs.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
These private functions with names like monCommand and pgCommand were no
different from the public xxxCommandWithInputBuffer commands. Thus the
redundant private functions are removed to simplify the file. As private
functions these can be added back later w/o fuss if the behavior of
the xxxCommand and xxxCommandWithInputBuffer calls need to differ more
in the future.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Use the CephStatx type previously added to the library to implement a
wrapper for the ceph_fstatx function.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add the ReadDirPlus function call, wrapping ceph_readdirplus_r. Add
DirEntryPlus which is a DirEntry plus a getter for the statx field.
Add a test similar to the ReadDir test and (since it is possible to
induce an error with ceph_readdirplus_r) a test for the error handling
path to improve code coverage.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This is a dev tool mainly for just those of us who work on the project,
so this is mainly just a quick-start type description.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
To be clearer about what the tool detects, rename "covered" to "found"
such as not to indicate an undocumented but used function is considered
"covered". Future arguments about what "covered" really means to be
scheduled at a later date. :-)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Currently, annotating the functions (are they documented, deprecated,
etc) in the function listing is not very costly and there are very
few situations where that extra information would be unwanted. Just
annotate the listing every time when running the tool.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Right now the tool doesn't do much checking but it does check what is
implemented, so we call the rule 'check-implements'. All current
sub-packages are checked. Use IMPLEMENTS_OPTS to pass additional cli
options to the tool.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The implements tool, when compiled, is named implements [1]. We never
want git to track it.
1 - Shocking, I know!
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Allowing the tool to generate a JSON report makes it easier to add
additional tools later to make use of this data, without hand parsing
the text output.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add simple reporting functionality to the implements package that is
intended to mimic the output of the current contrib/apicompare.py
script.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add a file for processing C sources using the `castxml` tool. This tool
produces XML describing a C AST. This file adds go code for invoking the
tool and minimal processing of the XML it generates.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This code makes use of Go's native AST processing packages and allows us
to analyze our source code using the go-ceph conventions.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This log.go file establishes the ability for the package's user to hand
it any logger that meets the very minimal interface.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Previously, "make check" only ran revive and its static checks. The
entrypoint.sh script ran a formatting check *after* setting up ceph.
Now, "make check" runs both revive and gofmt. New make rules
check-revive and check-format run the individual tools respectively.
This is done to quicken the feedback in both the CI and locally for
formatting mistakes. Users can now easily run `make check
test-container` and avoid a long wait to set up ceph just to find out
there was a silly formatting error present.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The .test files are generated by some makefile rules and should
never be checked in.
There's also no reason to track json files which may be generated
by running tools.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The *_command functions in librados and libcephfs document the use
of specific free functions for data allocated. These functions are
currently just wrappers around C's free() function. However, to be
more strictly compliant this change adds a free-function callback
to the CommandOutput type and the specific free functions are now
used outside the unit tests.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Similar to the functions in the rados pkg, cephfs package has a function
MdsCommand that is mostly boilerplate that to set up the C function's
arguments. Replace it with the types from the new cutil internal
package.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Replace the argument handling (wrangling?) around *_command functions,
such as MonCommand, with the new command input and output helper types
from the internal/cutil package.
No external change should be visible.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Now we have sufficient boilerplate in our code for interacting with
various types and ceph calls with similar needs we establish a new
internal package, "cutil" (C utilities).
Note that many of the return types are wrapped. This is due to the
limits placed on us by cgo. Despite the irritating limitations Go
places on "exporting" C types it still ought to help in the long run for
patterns that are very common or patterns that are subtle and we want to
write specific tests for.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add a Statx wrapper for ceph_statx.
Add a type wrapping the statx status info that exposes the various
fields from the C-struct.
Add a type wrapping struct timespec, based on golang's x/sys, for the
time fields in the struct.
Note that the ceph struct is not the same as the linux statx struct.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
ceph MountInfo pointer is being passed in the functions without a validation check, if it is nil there may be a crash. Fixed the functions to first validate mount.mount
Signed-off-by: Mudit Agarwal muagarwa@redhat.com
Link function implements ceph_link().
Symlink function implements ceph_symlink().
Readlink function implements ceph_readlink().
To fix https://github.com/ceph/go-ceph/issues/218
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
CephFS returns Linux-style struct dirent that has a d_type field.
It appears to properly make use of the field. This change exposes
the field using a DType type and associated constants as well
as a DType() function for the DirEntry.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Negative offsets that are passed through ReadAt/WriteAt to the ceph
calls cause them to behave like Read/Write and this is undesirable
at the go layer. Additionally, the os packages' file functions
reject negative offsets as well.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add a test case to ensure the behavior of a mixed used [1] of Read
and ReadAt calls is consistent and ReadAt doesn't side effect
the file position used by Read.
1 - Not recommended, but we should not break now or in the future.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Have Read and ReadAt functions return io.EOF when nothing is read
from the file so that it matches the current behavior of file types
in Go standard library.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Now, the close function is idempotent wrt being called multiple times
on a valid file. Additionally, check the state of the file in various
functions to produce sensible errors, matching those cephfs itself
returns, if the object was not constructed properly.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add functions for issuing commands to ceph mgrs with
MgrCommand and MgrCommandWithInputBuffer, implemented simliarly
to the other *Command style functions.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Organize the rados package a bit more by moving functions that wrap
rados_xyz_command functions into a dedicated file. Move related test to
a separate file as well.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
make test-container is failing on Fedora based distribution because of bad label option "disabled".
Change label option to "disable"
Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>