1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #2566 from kushalsingh007/fd

Changed description for fd_t::fd in sys/include/fd.h
This commit is contained in:
Oleg Hahm 2015-03-12 09:09:45 +01:00
commit 7256a1399a
5 changed files with 13 additions and 13 deletions

View File

@ -4,7 +4,7 @@ simple appserver (all in one shell)
0. create tap devices: *./cpu/native/tapsetup.sh create 3*
1. build ccn-lite-client: *make -B clean all-valgrind*
2. start: *./bin/native/ccn-lite-client.elf tap0* (valgrind support included)
3. optinonal: *config 20* [enter] (this sets the content store size)
3. optional: *config 20* [enter] (this sets the content store size)
4. start appserver thread: *appserver* [enter] (this starts the userland appserver, which registers for "/riot/appserver/"
5. request content: *interest /riot/appserver/test* [enter] (ask the relay for this "file", userland code splits this up in
chunks and requests them from the relay. In the relay the name "/riot/appserver" is registered to the RIOT MSG face with

View File

@ -34,13 +34,13 @@ extern "C" {
*/
typedef struct {
/** private status of this fd_t */
int __active;
int internal_active;
/** the internal filedescriptor */
int fd;
/** Stores the RIOT internal value for the file descriptor (not POSIX). */
int internal_fd;
/**
* Read *n* into *buf* from *fd*. Return the
* Read *n* bytes into *buf* from *fd*. Return the
* number read, -1 for errors or 0 for EOF.
*/
ssize_t (*read)(int fd, void *buf, size_t n);

View File

@ -43,8 +43,8 @@ int fd_init(void)
#ifdef MODULE_UART0
posix_open(uart0_handler_pid, 0);
fd_t fd = {
.__active = 1,
.fd = (int)uart0_handler_pid,
.internal_active = 1,
.internal_fd = (int)uart0_handler_pid,
.read = (ssize_t ( *)(int, void *, size_t))posix_read,
.write = (ssize_t ( *)(int, const void *, size_t))posix_write,
.close = posix_close
@ -61,7 +61,7 @@ static int fd_get_next_free(void)
for (int i = 0; i < FD_MAX; i++) {
fd_t *cur = &fd_table[i];
if (!cur->__active) {
if (!cur->internal_active) {
return i;
}
}
@ -77,8 +77,8 @@ int fd_new(int internal_fd, ssize_t (*internal_read)(int, void *, size_t),
if (fd >= 0) {
fd_t *fd_s = fd_get(fd);
fd_s->__active = 1;
fd_s->fd = internal_fd;
fd_s->internal_active = 1;
fd_s->internal_fd = internal_fd;
fd_s->read = internal_read;
fd_s->write = internal_write;
fd_s->close = internal_close;

View File

@ -45,7 +45,7 @@ int socket(int domain, int type, int protocol)
#define sock_func_wrapper(func, sockfd, ...) \
((fd_get(sockfd)) ? \
func(fd_get(sockfd)->fd, __VA_ARGS__) : \
func(fd_get(sockfd)->internal_fd, __VA_ARGS__) : \
(errno = EBADF, -1))
int accept(int socket, struct sockaddr *restrict address,

View File

@ -27,12 +27,12 @@ int close(int fildes)
return -1;
}
if (fd_obj->close(fd_obj->fd) < 0) {
if (fd_obj->close(fd_obj->internal_fd) < 0) {
errno = EIO; // EINTR may not occur since RIOT has no signals yet.
return -1;
}
fd_destroy(fd_obj->fd);
fd_destroy(fd_obj->internal_fd);
return 0;
}