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>
Our first operation is generating sizes for various caller-allocated
buffers. The WithSizes function "suggests" sizes to an anonymous
function that takes a size as an argument and returns a hint how
sucessful the attempt was. If required the same function is called
again with a larger size. Errors and other results of that anonymous
function are "communicated" with variables of the surrounding scope
in wich the function is defined.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: Sven Anderson <sven@redhat.com>
Continue organizing the cephfs functionality by creating new files
for chmod and chown functionality.
Similarly, the dedicated test functions for those items are moved
into a new file as well.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Continue organizing the cephfs functionality by creating new files
for the most basic path management functions:
MakeDir, RemoveDir, ChangeDir, CurrentDir
Similarly, the dedicated test functions for those items are moved into
a new file as well.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Start organizing some of the cephfs functionality into functions grouped
by files by moving the MDS command functions into a new file. Move the
tests dedicated to those functions into a new matching file too.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The Init functions initializes the connection without mounting the fs.
This function must be called before setting the perms but before
creating the mount.
SetMountPerms accepts a UserPerm object to set the fs ownership info
on the mount. The corresponding tests verifies that the UserPerm
can be applied and it effects the gid of newly created dirs for that
mount.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
To prevent test failures re-reunning the suite against the same fs we
need to make sure tests clean up after themselves.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Enable the revive rule to ensure we check the return values of various
function calls. Put common printing functions in the skip list of the
check, because no-one ever checks the error of those. :-)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
We already have a few functions with unwieldy number of arguments. Cap
the max number of arguments to allow at our current max (7) and cap
the number of return values at 3.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Now that we have no code that triggers this check, re-enable the
indent-error-flow check in the revive config.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Clean up the temporary file using a defer and make sure that the
errors returned by the functions in the defer func are checked.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The RewindDir is used by List and can be used independently. It
resets the open dir to the "start".
The List function and the accompanying DirEntries type allow one
to simply grab all the dir entries at once. The Names method on the
DirEntries type allows the user to get the most commonly wanted items
from the dir entries in one shot.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add the Directory type and the OpenDir function to get an open
Directory and a Close function to close/free it.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
revive would only fail if rbd had errors due to the loop being in shell.
Now we expand the modules list as arguments to revive which then
invokes revive only once and properly handles errors.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This should basically run similarly to the travis ci configuration
but use the native github ci infrastructure.
In order to avoid messing around with various env vars I had to use the
v2-beta version of the go setup library. Once v2 has been released
we can switch away from the beta.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
For more consisistency use getError where possible.
Changes produced using `gofmt -r 'RadosError(int(x)) -> getError(x)`,
followed by a few manual fixups.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Mention the env vars that the go test code looks for but does not change
from the "outer" environment as a way of documenting those variables.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Previously, calling Release more than once for the same MountInfo would
abort due to a double free in the ceph libs. As this is somewhat user
hostile we add some simple state tracking in our wrapper type such that
one can make redundant calls to Release without crashing the
application.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The test function that exercises ChangeDir was creating a directory
and leaving it behind. Add some basic cleanup to the test to try
and avoid leaking stuff between test runs.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
In a previous commit we added fsDisconnect to match with fsConnect. For
tests that do not use fsConnect but still acquire resources we need to
free up those resources with direct calls to the appropriate functions.
Signed-off-by: John Mulligan <jmulligan@redhat.com>