X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FIPStack%2Fadapters.c;h=deb05528f68f10381c133164989455a7daf6ff4c;hb=d0b4559f2936f6d9f06be0f7c3c51527a480ec0d;hp=90c0b24510d3a47ac7522cc29089f49ad650a9de;hpb=94d1376ee39e709225c895eb22c71ff3240e3254;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/IPStack/adapters.c b/KernelLand/Modules/IPStack/adapters.c index 90c0b245..deb05528 100644 --- a/KernelLand/Modules/IPStack/adapters.c +++ b/KernelLand/Modules/IPStack/adapters.c @@ -20,7 +20,7 @@ void *IPStack_Adapter_Add(const tIPStack_AdapterType *Type, void *Ptr, const void *HWAddr); void IPStack_Adapter_Del(void *Handle); // --- VFS API --- -char *Adapter_ReadDir(tVFS_Node *Node, int Pos); + int Adapter_ReadDir(tVFS_Node *Node, int Pos, char Name[FILENAME_MAX]); tVFS_Node *Adapter_FindDir(tVFS_Node *Node, const char *Name); int Adapter_DirIOCtl(tVFS_Node *Node, int Num, void *Data); int Adapter_IOCtl(tVFS_Node *Node, int Num, void *Data); @@ -85,8 +85,8 @@ void *IPStack_Adapter_Add(const tIPStack_AdapterType *Type, void *Ptr, const voi Mutex_Release( &glIP_Adapters ); // Watch the adapter for incoming packets - tTID tid = Proc_SpawnWorker(Adapter_int_WatchThread, ret); - if(tid < 0) { + void *worker = Proc_SpawnWorker(Adapter_int_WatchThread, ret); + if(!worker) { Log_Warning("IPStack", "Unable to create watcher thread for %p", ret); } @@ -130,13 +130,14 @@ void IPStack_Adapter_Del(void *Handle) } // --- VFS API --- -char *Adapter_ReadDir(tVFS_Node *Node, int Pos) +int Adapter_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]) { - if( Pos < 0 ) return NULL; + if( Pos < 0 ) return -EINVAL; // Loopback if( Pos == 0 ) { - return strdup("lo"); + strcpy(Dest, "lo"); + return 0; } Pos --; @@ -144,7 +145,8 @@ char *Adapter_ReadDir(tVFS_Node *Node, int Pos) tAdapter *a; int i;\ for(i=0,a=list; i < Pos && a; i ++, a = a->Next ); \ if( a ) { \ - return Adapter_GetName(a);\ + strncpy(Dest, Adapter_GetName(a), FILENAME_MAX);\ + return 0;\ } \ Pos -= i; \ } while(0); @@ -152,7 +154,7 @@ char *Adapter_ReadDir(tVFS_Node *Node, int Pos) CHECK_LIST(gpIP_AdapterList, "eth"); // TODO: Support other types of adapters (wifi, tap, ...) - return NULL; + return -EINVAL; } tVFS_Node *Adapter_FindDir(tVFS_Node *Node, const char *Name) @@ -344,7 +346,9 @@ void IPStack_SendDebugText(const char *Text) if( CPU_HAS_LOCK(&lLock) ) return ; // Nested! SHORTLOCK(&lLock); + #if ARCHDIR_is_x86 __asm__ __volatile__ ("sti"); // Start interrupts (x86 specific) + #endif // Cache packets until a newline static char cache[1500 - (sizeof(pkt_hdr) + 4)];