#include <assert.h>
#include <errno.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/queue.h>
#include "sysio.h"
return NULL;
_SYSIO_FINIT(fil, ino, flags);
+ F_REF(fil);
I_REF(ino);
return fil;
assert(!fil->f_ref);
assert(fil->f_ino);
err = (*fil->f_ino->i_ops.inop_close)(fil->f_ino);
+ I_RELE(fil->f_ino);
assert(!err);
free(fil);
}
return 0;
}
-#if ZERO_SUM_MEMORY
+#ifdef ZERO_SUM_MEMORY
static void free_oftab(oftab_t *ot)
{
if (ot->table) {
{
struct file *fil;
- fil = fil = __sysio_fd_get(fd, 1);
+ fil = __sysio_fd_get(fd, 1);
if (!fil)
return -EBADF;
init_oftab();
- if (oldfd == newfd)
- return 0;
+ if (oldfd == newfd && oldfd >= 0)
+ return newfd;
fil = _sysio_fd_find(oldfd);
if (!fil)
int
_sysio_fd_close_all()
{
- int fd;
- struct file **filp;
- oftab_t *oftab;
- int i;
-
- /*
- * Close all open descriptors.
- */
+ /* Close all open descriptors */
_sysio_oftable_close_all(&_sysio_oftab[OFTAB_VIRTUAL]);
- /* XXX see liblustre/llite_lib.c for explaination */
+ /* FIXME: libsysio does not currently perform enough cleanup of
+ * open files to allow __liblustre_cleanup_() to safely call
+ * unmount(). See the related FIXME comment in that function
+ * for details. The following disabled code is left in place to
+ * document the solution that was originally under consideration
+ * but never fully implemented. */
#if 0
_sysio_oftable_close_all(&_sysio_oftab[OFTAB_NATIVE]);
#endif
- /*
- * Release current working directory.
- */
+ /* Release current working directory */
if (_sysio_cwd) {
P_RELE(_sysio_cwd);
_sysio_cwd = NULL;