@@ -379,7 +379,7 @@ int vfs_clone_fd(int *fd_src, int *fd_dst)
379379
380380/**************************** Syscall implementation ****************************/
381381
382- int do_read ( int fd , void * buffer , int count )
382+ SYSCALL_DEFINE3 ( read , int , fd , void * , buffer , int , count )
383383{
384384 int gfd ;
385385 int ret ;
@@ -427,7 +427,7 @@ int do_read(int fd, void *buffer, int count)
427427/**
428428 * @brief This function writes a REGULAR FILE/FOLDER. It only support regular file, dirs and pipes
429429 */
430- int do_write ( int fd , const void * buffer , int count )
430+ SYSCALL_DEFINE3 ( write , int , fd , const void * , buffer , int , count )
431431{
432432 int gfd ;
433433 int ret ;
@@ -474,7 +474,7 @@ int do_write(int fd, const void *buffer, int count)
474474/**
475475 * @brief This function opens a file. Not all file types are supported.
476476 */
477- int do_open ( const char * filename , int flags )
477+ SYSCALL_DEFINE2 ( open , const char * , filename , int , flags )
478478{
479479 int fd , gfd , ret = -1 ;
480480 uint32_t type ;
@@ -542,7 +542,7 @@ int do_open(const char *filename, int flags)
542542 * @brief readdir read a directory entry which will be stored in a struct dirent entry
543543 * @param fd This is the file descriptor provided as (DIR *) when doing opendir in the userspace.
544544 */
545- int do_readdir ( int fd , char * buf , int len )
545+ SYSCALL_DEFINE3 ( readdir , int , fd , char * , buf , int , len )
546546{
547547 struct dirent * dirent ;
548548 int gfd ;
@@ -588,13 +588,13 @@ int do_readdir(int fd, char *buf, int len)
588588 * only when refcount is equal to zero (no more reference on the gfd).
589589 * @param fd This is the local fd from the process' table.
590590 */
591- void do_close ( int fd )
591+ SYSCALL_DEFINE1 ( close , int , fd )
592592{
593593 pcb_t * pcb = current ()-> pcb ;
594594 int gfd ;
595595
596596 if ((!pcb ) || (fd < 0 ))
597- return ;
597+ return 0 ;
598598
599599 mutex_lock (& vfs_lock );
600600
@@ -604,12 +604,12 @@ void do_close(int fd)
604604 if (gfd < 0 ) {
605605 LOG_DEBUG ("Was already freed\n" );
606606 mutex_unlock (& vfs_lock );
607- return ;
607+ return 0 ;
608608 }
609609
610610 if (!open_fds [gfd ]) {
611611 mutex_unlock (& vfs_lock );
612- return ;
612+ return 0 ;
613613 }
614614
615615 /* Decrement reference counter to keep track of open fds */
@@ -640,13 +640,15 @@ void do_close(int fd)
640640 }
641641
642642 mutex_unlock (& vfs_lock );
643+
644+ return 0 ;
643645}
644646
645647/**
646648 * @brief dup2 creates a synonym of oldfd on newfd
647649 *
648650 */
649- int do_dup2 ( int oldfd , int newfd )
651+ SYSCALL_DEFINE2 ( dup2 , int , oldfd , int , newfd )
650652{
651653 if ((newfd < 0 ) || (newfd > MAX_FDS ))
652654 return - EBADF ;
@@ -680,7 +682,7 @@ int do_dup2(int oldfd, int newfd)
680682 * @param File descriptor to copy.
681683 * @return A copy of the file descriptor.
682684 */
683- int do_dup ( int oldfd )
685+ SYSCALL_DEFINE1 ( dup , int , oldfd )
684686{
685687#ifdef CONFIG_PROC_ENV
686688 int newfd ;
@@ -708,7 +710,7 @@ int do_dup(int oldfd)
708710#endif
709711}
710712
711- int do_stat ( const char * path , struct stat * st )
713+ SYSCALL_DEFINE2 ( stat , const char * , path , struct stat * , st )
712714{
713715 int ret ;
714716
@@ -737,7 +739,7 @@ int do_stat(const char *path, struct stat *st)
737739/**
738740 * An mmap() implementation in VFS.
739741 */
740- void * do_mmap ( addr_t start , size_t length , int prot , int fd , off_t offset )
742+ SYSCALL_DEFINE5 ( mmap , addr_t , start , size_t , length , int , prot , int , fd , off_t , offset )
741743{
742744 int gfd ;
743745 uint32_t page_count ;
@@ -749,7 +751,7 @@ void *do_mmap(addr_t start, size_t length, int prot, int fd, off_t offset)
749751 if (-1 == gfd ) {
750752 printk ("%s: could not get global fd.\n" , __func__ );
751753 set_errno (EBADF );
752- return MAP_FAILED ;
754+ return ( long ) MAP_FAILED ;
753755 }
754756
755757 mutex_lock (& vfs_lock );
@@ -758,7 +760,7 @@ void *do_mmap(addr_t start, size_t length, int prot, int fd, off_t offset)
758760 printk ("%s: could not get device fops.\n" , __func__ );
759761 mutex_unlock (& vfs_lock );
760762 set_errno (EBADF );
761- return MAP_FAILED ;
763+ return ( long ) MAP_FAILED ;
762764 }
763765
764766 mutex_unlock (& vfs_lock );
@@ -772,14 +774,14 @@ void *do_mmap(addr_t start, size_t length, int prot, int fd, off_t offset)
772774 if (!fops -> mmap ) {
773775 printk ("%s: device doesn't support mmap.\n" , __func__ );
774776 set_errno (EACCES );
775- return MAP_FAILED ;
777+ return ( long ) MAP_FAILED ;
776778 }
777779
778780 /* Call the mmap fops that will do the actual mapping. */
779- return fops -> mmap (fd , start , page_count , offset );
781+ return ( long ) fops -> mmap (fd , start , page_count , offset );
780782}
781783
782- int do_ioctl ( int fd , unsigned long cmd , unsigned long args )
784+ SYSCALL_DEFINE3 ( ioctl , int , fd , unsigned long , cmd , unsigned long , args )
783785{
784786 int rc , gfd ;
785787 mutex_lock (& vfs_lock );
@@ -808,7 +810,7 @@ int do_ioctl(int fd, unsigned long cmd, unsigned long args)
808810 * Implementation of standard lseek() syscall. It depends on the underlying
809811 * device operations.
810812 */
811- off_t do_lseek ( int fd , off_t off , int whence )
813+ SYSCALL_DEFINE3 ( lseek , int , fd , off_t , off , int , whence )
812814{
813815 int rc , gfd ;
814816 mutex_lock (& vfs_lock );
@@ -834,7 +836,7 @@ off_t do_lseek(int fd, off_t off, int whence)
834836/*
835837 * Implementation of the fcntl syscall
836838 */
837- int do_fcntl ( int fd , unsigned long cmd , unsigned long args )
839+ SYSCALL_DEFINE3 ( fcntl , int , fd , unsigned long , cmd , unsigned long , args )
838840{
839841 /* Not yet implemented */
840842
0 commit comments