2 * Copyright (C) 2020 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by the
6 * Free Software Foundation; version 2.1 of the License.
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <common/macros.h>
27 * Marks the handle as the most recently used and marks the 'fd' as
28 * "in-use". This prevents the tracker from recycling the underlying
29 * file descriptor while it is actively being used by a thread.
31 * Don't forget that the tracker may be initiating an fd 'suspension'
32 * from another thread as the need to free an fd slot may arise from any
33 * thread within the daemon.
35 * Note that a restorable fd should never be held for longer than
36 * strictly necessary (e.g. the duration of a syscall()).
38 * Returns the fd on success, otherwise a negative value may be returned
39 * if the restoration of the fd failed.
42 int fs_handle_get_fd(struct fs_handle
*handle
);
45 * Used by the caller to signal that it is no longer using the underlying fd and
46 * that it may be safely suspended.
49 void fs_handle_put_fd(struct fs_handle
*handle
);
52 * Unlink the file associated to an fs_handle. Note that the unlink
53 * operation will not be performed immediately. It will only be performed
54 * once all references to the underlying file (through other fs_handle objects)
57 * However, note that the file will be renamed so as to provide the observable
58 * effect of an unlink(), that is removing a name from the filesystem.
60 * Returns 0 on success, otherwise a negative value will be returned
61 * if the operation failed.
64 int fs_handle_unlink(struct fs_handle
*handle
);
67 * Frees the handle and discards the underlying fd.
70 int fs_handle_close(struct fs_handle
*handle
);
73 ssize_t
fs_handle_read(struct fs_handle
*handle
, void *buf
, size_t count
);
76 ssize_t
fs_handle_write(struct fs_handle
*handle
, const void *buf
, size_t count
);
79 int fs_handle_truncate(struct fs_handle
*handle
, off_t offset
);
82 int fs_handle_seek(struct fs_handle
*handle
, off_t offset
, int whence
);
84 #endif /* FS_HANDLE_H */
This page took 0.031826 seconds and 5 git commands to generate.