New upstream version 8.1.0
This commit is contained in:
33
client_module/source/common/system/System.c
Normal file
33
client_module/source/common/system/System.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <common/toolkit/StringTk.h>
|
||||
#include <linux/utsname.h>
|
||||
#include "System.h"
|
||||
|
||||
char* System_getHostnameCopy(void)
|
||||
{
|
||||
// note: this is racy since 2.6.27 unexported uts_sem. however, NFS (fs/nfs/nfsroot.c) and
|
||||
// CIFS (fs/cifs/connect.c) use utsname()->nodename without the semaphore.
|
||||
// we'll have to keep an eye on it...
|
||||
|
||||
char* hostnameOrig;
|
||||
char* hostnameCopy;
|
||||
|
||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,26)
|
||||
down_read(&uts_sem);
|
||||
#endif
|
||||
|
||||
#ifdef KERNEL_HAS_SYSTEM_UTSNAME
|
||||
hostnameOrig = system_utsname.nodename;
|
||||
#else
|
||||
hostnameOrig = utsname()->nodename;
|
||||
#endif
|
||||
|
||||
hostnameCopy = kmalloc(strlen(hostnameOrig)+1, GFP_KERNEL);
|
||||
if(likely(hostnameCopy) )
|
||||
strcpy(hostnameCopy, hostnameOrig);
|
||||
|
||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,26)
|
||||
up_read(&uts_sem);
|
||||
#endif
|
||||
|
||||
return hostnameCopy;
|
||||
}
|
||||
8
client_module/source/common/system/System.h
Normal file
8
client_module/source/common/system/System.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef SYSTEM_H_
|
||||
#define SYSTEM_H_
|
||||
|
||||
#include <common/Common.h>
|
||||
|
||||
extern char* System_getHostnameCopy(void);
|
||||
|
||||
#endif /*SYSTEM_H_*/
|
||||
Reference in New Issue
Block a user