148 if ( file->
fd ==
fd )
166 DBG (
"POSIX could not find free file descriptor\n" );
176 int open (
const char *uri_string ) {
187 file =
zalloc (
sizeof ( *file ) );
213 DBG (
"POSIX opened %s as file %d\n", uri_string,
fd );
235 if ( ! FD_ISSET (
fd, readfds ) )
245 FD_SET (
fd, readfds );
#define iob_pull(iobuf, len)
An object interface operation.
struct arbelprm_rc_send_wqe rc
void intf_close(struct interface *intf, int rc)
Close an object interface.
struct list_head list
List of open files.
struct interface xfer
Data transfer interface.
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
#define list_add(new, head)
Add a new entry to the head of a list.
#define XFER_FL_ABS_OFFSET
Offset is absolute.
#define ref_init(refcnt, free)
Initialise a reference counter.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
ssize_t read_user(int fd, userptr_t buffer, off_t offset, size_t max_len)
Read data from file.
int close(int fd)
Close file.
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
struct refcnt refcnt
Reference count for this object.
A doubly-linked list entry (or list head)
Data transfer interfaces.
#define list_empty(list)
Test whether a list is empty.
#define list_del(list)
Delete an entry from a list.
ssize_t fsize(int fd)
Determine file size.
#define ENOMEM
Not enough space.
uint32_t userptr_t
A pointer to a user buffer.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
#define EWOULDBLOCK
Operation would block.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
static int posix_file_xfer_deliver(struct posix_file *file, struct io_buffer *iobuf, struct xfer_metadata *meta)
Handle deliver_iob() event.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
static LIST_HEAD(posix_files)
List of open files.
#define EBADF
Bad file descriptor.
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
#define EINPROGRESS
Operation in progress.
#define POSIX_FD_MAX
Maximum file descriptor that will ever be allocated.
uint32_t fd_set
File descriptor set as used for select()
An object interface descriptor.
static struct interface_operation posix_file_xfer_operations[]
POSIX file data transfer interface operations.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define POSIX_FD_MIN
Minimum file descriptor that will ever be allocated.
#define ENFILE
Too many open files in system.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
static __always_inline void copy_to_user(userptr_t dest, off_t dest_off, const void *src, size_t len)
Copy data to user buffer.
static void posix_file_finished(struct posix_file *file, int rc)
Terminate file data transfer.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
static void posix_file_free(struct refcnt *refcnt)
Free open file.
int select(fd_set *readfds, int wait)
Check file descriptors for readiness.
Data transfer interface opening.
static struct interface_descriptor posix_file_xfer_desc
POSIX file data transfer interface descriptor.
static struct posix_file * posix_fd_to_file(int fd)
Identify file by file descriptor.
#define INIT_LIST_HEAD(list)
Initialise a list head.
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
struct list_head list
List of which this buffer is a member.
struct list_head data
Received data queue.
void * data
Start of data.
void step(void)
Single-step a single process.
int open(const char *uri_string)
Open file.
size_t pos
Current seek position.
static int posix_find_free_fd(void)
Find an available file descriptor.
uint16_t offset
Offset to command line.
#define DBG(...)
Print a debugging message.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
int xfer_open_uri_string(struct interface *intf, const char *uri_string)
Open URI string.
size_t filesize
File size.
#define NULL
NULL pointer (VOID *)
#define ref_put(refcnt)
Drop reference to object.