Programming/c# & winform2020. 9. 29. 11:47

effective c#에서 item #4 내용

 

#if defined(__DEBUG__)
#endif

류의 preprocessor 쪽 문장들은 유지보수도 힘드니까

 

[Conditional("DEBUG")]

로 깔끔하게 조건에 따라서 릴리즈 모드에서는 배제 되도록 하는 문구.

어떻게 보면.. Java의 annotation 느낌이긴 하다?

 

해당 조건을 쓰기 위해서는 /define 명령을 이용해서 미리 선언을 해주어야 한다.

gcc에서 -D 쓰는 느낌? ㅋ

컴파일러 명령줄 옵션을 사용 합니다. 예를 들어 /define: DEBUG입니다.

[링크 : https://docs.microsoft.com/ko-kr/dotnet/api/system.diagnostics.conditionalattribute?view=netcore-3.1]

'Programming > c# & winform' 카테고리의 다른 글

c# @문자열  (0) 2020.10.05
winform socket  (0) 2020.09.29
mono로 sln 프로젝트 빌드가 되네?  (2) 2020.09.28
c# 오버라이드, 하이드, 쉐도우  (0) 2020.09.23
c# 상속  (0) 2020.09.23
Posted by 구차니
Linux API/linux2020. 9. 28. 17:54

많이 쓰지 않다 보니 잊고 있었는데

open() 시스템 콜 사용에서 퍼미션 설정시 0644라고 해야지 644로 하면 이상한 퍼미션으로 생성된다.

원인을 찾다보니.. 0644 라고 써야 할걸 귀찮아서(?!) 644라고 썼더니 오작동 한 것 같은데

16진수가 아니라 굳이 8진법을 쓰는 이유는

rwx로 조합되는 것이 2^3 = 8 이기 때문 이려나?

 

새삼 이런데서 8진법으로 표기한다는게 신기하네..

 

--w----r-T

아무튼 644로 표기하면 위의 희한한 퍼미션으로 생성된다.

T니까.. stikcy bit고.. 이거 1000(8) 일텐데

 

644(10) = 1204(8) = 284(16)

더럽게(!) 우연히 1000(8)이 들어가 버렸네?

 

 

[링크 : https://blog.naver.com/tipsware/221498204578]

'Linux API > linux' 카테고리의 다른 글

spi 통신 예제(linux)  (0) 2021.01.28
linux USB bulk 통신  (0) 2020.10.21
open with O_CREAT or O_TMPFILE in second argument needs 3 arguments  (0) 2020.09.28
open() read() write() close()를 이용한 cp 예제  (0) 2020.09.28
fopen64  (0) 2019.06.24
Posted by 구차니
Linux API/linux2020. 9. 28. 17:43

빌드하다 보니 이상한 에러 발생

 

error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments

 

원인은 open() 의 인자가 2개에서 3개로 늘어서 그렇다는데

vscode 에서 따라가서 봐도 인자는 2개 이상이면 문제가 없어야 하는데... 머지?

__fortify_function int

open (const char *__path, int __oflag, ...)

{

if (__va_arg_pack_len () > 1 __open_too_many_args ();

 

if (__builtin_constant_p (__oflag))

{

        if (__OPEN_NEEDS_MODE (__oflag) && __va_arg_pack_len () < 1)

        {

                __open_missing_mode ();

                return __open_2 (__path, __oflag);

        }

        return __open_alias (__path, __oflag, __va_arg_pack ());

}

 

if (__va_arg_pack_len () < 1) return __open_2 (__path, __oflag);

 

return __open_alias (__path, __oflag, __va_arg_pack ());

}

 

일단은 추적을 해보니 O_CREAT가 0이 아니거나 O_TMP_FILE이 설정되어 있을 경우

/* Detect if open needs mode as a third argument (or for openat as a fourth

argument). */

#ifdef __O_TMPFILE

# define __OPEN_NEEDS_MODE(oflag) \

(((oflag) & O_CREAT) != 0 || ((oflag) & __O_TMPFILE) == __O_TMPFILE)

#else

# define __OPEN_NEEDS_MODE(oflag) (((oflag) & O_CREAT) != 0)

#endif

 

그리고 인자가 1보다 작을 경우(즉, 퍼미션 이 없으면)

/* GCC 4.3 and above allow passing all anonymous arguments of an

__extern_always_inline function to some other vararg function. */

#if __GNUC_PREREQ (4,3)

# define __va_arg_pack() __builtin_va_arg_pack ()

# define __va_arg_pack_len() __builtin_va_arg_pack_len ()

#endif

 

아래를 수행해야 하는데 __open_missing_mode()는 따라가지지 않고

원래대로라면 __open_2(__path, __oflag) 으로 연결되어야 하는데 왜 에러가 난 걸까?

                __open_missing_mode ();

                return __open_2 (__path, __oflag);

[링크 : https://damduc.tistory.com/316]

 

+

/usr/include$ grep -rni "__errordecl" ./
./x86_64-linux-gnu/sys/cdefs.h:125:# define __errordecl(name, msg) \

별거 아닌.. 에러문 출력하는 선언문 인듯 한데..

# define __errordecl(name, msg) \
  extern void name (void) __attribute__((__error__ (msg)))
#else
# define __warndecl(name, msg) extern void name (void)
# define __warnattr(msg)
# define __errordecl(name, msg) extern void name (void)
#endif

 

정리를 하자면 O_CREAT, O_TMPFILE이 존재할 경우

컴파일 단계에서 __open_missing_mode (); 에 도달시 에러를 내고

그 다음 return으로 도달하지 못한다. 그리고 해당 항목은 GCC 4.3 이후 버전에서

인자를 확인하도록 추가되면서 영향을 받았다. 라고 해석을 해야 할 듯?

 

4.3 이후에 추가된 버그라고 봐야 하나?

 

if (__builtin_constant_p (__oflag))

{

        if (__OPEN_NEEDS_MODE (__oflag) && __va_arg_pack_len () < 1)

        {

                __open_missing_mode ();

                return __open_2 (__path, __oflag);

        }

        return __open_alias (__path, __oflag, __va_arg_pack ());

}

'Linux API > linux' 카테고리의 다른 글

linux USB bulk 통신  (0) 2020.10.21
linux open() 과 8진법  (0) 2020.09.28
open() read() write() close()를 이용한 cp 예제  (0) 2020.09.28
fopen64  (0) 2019.06.24
ubuntu iio rotate key 찾기 또 실패  (0) 2019.05.27
Posted by 구차니
Linux API/linux2020. 9. 28. 16:23

예제 보고 대충 따라서 만들어 봄

stdio.h를 했더니 fopen이랑 추천해주고 있어서 부랴부랴 찾아보니 unistd.h를 쓰라네?

cp.c:18:9: warning: implicit declaration of function ‘read’; did you mean ‘fread’? [-Wimplicit-function-declaration]
   len = read(fd_src, buff, BUFF_LEN);
         ^~~~
         fread
cp.c:20:4: warning: implicit declaration of function ‘write’; did you mean ‘fwrite’? [-Wimplicit-function-declaration]
    write(fd_dst, buff, len);
    ^~~~~
    fwrite
cp.c:25:2: warning: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration]
  close(fd_src);
  ^~~~~
  pclose

 

예외처리 하나도 없이 인자만 받아서 복사하는 cp 명령의 마이너 버전 코드.

#include <unistd.h>
#include <fcntl.h>

#define BUFF_LEN 4096

int main(int argc, char** argv)
{
        int fd_src = 0;
        int fd_dst = 0;
        int len = 0;
        char buff[BUFF_LEN];

        fd_src = open(argv[1], O_RDONLY);
        fd_dst = open(argv[2], O_CREAT | O_TRUNC | O_RDWR);

        while(1)
        {
                len = read(fd_src, buff, BUFF_LEN);
                if(len > 0)
                        write(fd_dst, buff, len);
                else
                        break;
        }

        close(fd_src);
        close(fd_dst);

}

 

[링크 : https://reakwon.tistory.com/39]

[링크 : https://linux.die.net/man/3/open]

[링크 : https://linux.die.net/man/2/close]

 

 

fstat으로 파일 길이 알아내기

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

#include <sys/types.h>
#include <sys/stat.h>

#define BUFF_LEN 4096

int main(int argc, char** argv)
{
	int fd_src = 0;
	int fd_dst = 0;
	int len = 0;
	char buff[BUFF_LEN];
	struct stat statbuf;

	fd_src = open(argv[1], O_RDONLY);
	fd_dst = open(argv[2], O_CREAT | O_TRUNC | O_RDWR);

	fstat(fd_src, &statbuf);
	printf("filename : [%s], length [%ld]\n", argv[1], statbuf.st_size);

	while(1)
	{
		len = read(fd_src, buff, BUFF_LEN);
		if(len > 0)
			write(fd_dst, buff, len);
		else
			break;
	}

	close(fd_src);
	close(fd_dst);

}

 

[링크 : https://man7.org/linux/man-pages/man2/stat.2.html]

'Linux API > linux' 카테고리의 다른 글

linux open() 과 8진법  (0) 2020.09.28
open with O_CREAT or O_TMPFILE in second argument needs 3 arguments  (0) 2020.09.28
fopen64  (0) 2019.06.24
ubuntu iio rotate key 찾기 또 실패  (0) 2019.05.27
전원버튼 IRQ 발생 관련  (0) 2018.04.23
Posted by 구차니
Programming/c# & winform2020. 9. 28. 11:13

오.. 신기신기..

어떻게 빌드하지?하다가

아무생각 없이 그냥 해당 프로젝트 디렉토리 들어가니 mono develop 아이콘이 똭!

더블 클릭해서 실행하니 mono develop  가 뜨고 빌드 옵션을 Debug에서 Release로 바꾸고

빌드하니

 

띠용.. PE32 executable 이 뜬다.

~/ar/bin/Release$ file *
ar.exe:        PE32 executable (GUI) Intel 80386 Mono/.Net assembly, for MS Windows
ar.exe.config: XML 1.0 document, UTF-8 Unicode (with BOM) text, with CRLF line terminators
ar.pdb:        Microsoft Rosyln C# debugging symbols version 1.0

 

물론 윈도우에서 프로젝트 파일 자체를 그대로 전송해 왔기 때문에

Deub로 가면 아래와 같이 나오는데 pdb는 메시지가 조금 다른데 exe는 리눅스 상에서 인식하는 포맷이 동일하게 나온다.

~/ar/bin/Debug$ file *
ar.exe:        PE32 executable (GUI) Intel 80386 Mono/.Net assembly, for MS Windows
ar.exe.config: XML 1.0 document, UTF-8 Unicode (with BOM) text, with CRLF line terminators
ar.pdb:        MSVC program database ver 7.00, 512*115 bytes

 

그나저나 4.7의 모든 것 이라고 해놓고

WPF, WWF 그리고 제한된 WCF 그리고 제한된 ASP.NET 비동기 stack을 제외한... (야이!!!)

Everything in .NET 4.7 except WPF, WWF, and with limited WCF and limited ASP.NET async stack.

[링크 : https://www.mono-project.com/docs/about-mono/compatibility/]

 

WWF는 처음 듣네? 검색해보니 레슬링이 왜 나오냐 ㅠㅠ

Windows Workflow Foundation

[링크 : https://docs.microsoft.com/ko-kr/dotnet/framework/windows-workflow-foundation/]

 

그냥 무난하게 winform으로 작성한건 그럼 리눅스에서 빌드하고 실행이 가능한데

GUI자체는 노가다 하거나 visual studio community에서 하는수 밖에 없나?

'Programming > c# & winform' 카테고리의 다른 글

winform socket  (0) 2020.09.29
c# conditional attribute  (0) 2020.09.29
c# 오버라이드, 하이드, 쉐도우  (0) 2020.09.23
c# 상속  (0) 2020.09.23
c#은 main()이 아니다 Main()이다 -_-  (0) 2020.09.23
Posted by 구차니

장보고 차 가져다 드리러 가니 차례 패스~ 하는걸로

그런데 무슨 기사가 떳나 아부지가 갑자기 그렇게 결정하실리가!??!?

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

추석 그리고 RTL-SDR  (0) 2020.10.01
추석 전날  (0) 2020.09.30
키즈카페 망한줄 알았는데  (0) 2020.09.26
버블건 수리  (0) 2020.09.13
피곤하다..  (0) 2020.08.30
Posted by 구차니

이번달 말까지로 바리스타 뽑는 공지가 워크넷에 있는거 보면...

망한줄 알았던 키즈카페가 아직 살아있는건가?

아니면 죽었다 재개장 했거나, 주인이 바뀐걸까?

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

추석 전날  (0) 2020.09.30
추석 차례 안지내기로 결정  (2) 2020.09.27
버블건 수리  (0) 2020.09.13
피곤하다..  (0) 2020.08.30
동네에 앰블런스가 옴  (0) 2020.08.29
Posted by 구차니

numatool 이라는걸 알아가게 되네..

NUMA는 복수개의 CPU를 사용할 때 버스를 통해서 메모리를 공유하고

SMP는 개별 CPU에 메모리를 달아 다른 CPU를 통해 메모리를 접근하는 방식으로 보임

(그러고 보니 펜3 시절에 SMP 라고 들은거 같은데 그때랑 지금의 2cpu 는 방식이 다른가?)

 

[링크 : https://12bme.tistory.com/537]

[링크 : https://rockball.tistory.com/entry/Numa의-이해]

[링크 : https://zetastring.tistory.com/85]

'이론 관련 > 컴퓨터 관련' 카테고리의 다른 글

온프레미스  (0) 2020.10.27
NMEA 포맷  (0) 2020.10.26
파일 스토리지, 블록 스토리지, 오브젝트 스토리지  (0) 2020.09.18
lustre file system  (0) 2020.09.18
smmu?  (0) 2020.09.08
Posted by 구차니

DTMF 에서 제정한 RESTfulAPI 표준으로 ipmi 정보를 받아오는 녀석들.

 

[링크 : https://github.com/DMTF/Redfishtool]

[링크 : https://pythonhosted.org/python-redfish/installation.html]

[링크 : http://redfish.dmtf.org/schemas/DSP0266_1.5.0.html]

 

+

[링크 : https://techhub.hpe.com/eginfolib/servers/docs/HPRestfultool/iLo4/data_model_reference.html]

[링크 : https://hewlettpackard.github.io/ilo-rest-api-docs/ilo4/]

'하드웨어 > Server Case & board' 카테고리의 다른 글

DCMI / IPMI, ipmiutil  (0) 2020.11.08
quanta F03 EP 서버 메뉴얼  (0) 2020.11.08
벤더별 ipmi 명칭  (0) 2020.09.24
nmap을 이용하여 ILO 포트 검색하기  (0) 2020.09.18
BMC(Board Management Controller) 제조업체  (0) 2020.09.18
Posted by 구차니
Linux/Ubuntu2020. 9. 24. 19:59

생각 난김에 설치해보는데 ipmi가 없는 일반 노트북에서는 에러가 나는건가..

 

$ sudo apt-get install ipmitool
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
다음의 추가 패키지가 설치될 것입니다 :
  freeipmi-common libfreeipmi16 libopenipmi0 openipmi
제안하는 패키지:
  freeipmi-tools
다음 새 패키지를 설치할 것입니다:
  freeipmi-common ipmitool libfreeipmi16 libopenipmi0 openipmi
0개 업그레이드, 5개 새로 설치, 0개 제거 및 4개 업그레이드 안 함.
1,985 k바이트 아카이브를 받아야 합니다.
이 작업 후 9,407 k바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까? [Y/n] 
받기:1 http://kr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 freeipmi-common amd64 1.4.11-1.1ubuntu4.1 [174 kB]
받기:2 http://kr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libfreeipmi16 amd64 1.4.11-1.1ubuntu4.1 [826 kB]
받기:3 http://kr.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 ipmitool amd64 1.8.18-5ubuntu0.1 [403 kB]
받기:4 http://kr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libopenipmi0 amd64 2.0.22-1.1ubuntu2.1 [450 kB]
받기:5 http://kr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openipmi amd64 2.0.22-1.1ubuntu2.1 [132 kB]
내려받기 1,985 k바이트, 소요시간 2초 (862 k바이트/초)
Selecting previously unselected package freeipmi-common.
(데이터베이스 읽는중 ...현재 242443개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../freeipmi-common_1.4.11-1.1ubuntu4.1_amd64.deb ...
Unpacking freeipmi-common (1.4.11-1.1ubuntu4.1) ...
Selecting previously unselected package libfreeipmi16.
Preparing to unpack .../libfreeipmi16_1.4.11-1.1ubuntu4.1_amd64.deb ...
Unpacking libfreeipmi16 (1.4.11-1.1ubuntu4.1) ...
Selecting previously unselected package ipmitool.
Preparing to unpack .../ipmitool_1.8.18-5ubuntu0.1_amd64.deb ...
Unpacking ipmitool (1.8.18-5ubuntu0.1) ...
Selecting previously unselected package libopenipmi0.
Preparing to unpack .../libopenipmi0_2.0.22-1.1ubuntu2.1_amd64.deb ...
Unpacking libopenipmi0 (2.0.22-1.1ubuntu2.1) ...
Selecting previously unselected package openipmi.
Preparing to unpack .../openipmi_2.0.22-1.1ubuntu2.1_amd64.deb ...
Unpacking openipmi (2.0.22-1.1ubuntu2.1) ...
freeipmi-common (1.4.11-1.1ubuntu4.1) 설정하는 중입니다 ...
libfreeipmi16 (1.4.11-1.1ubuntu4.1) 설정하는 중입니다 ...
libopenipmi0 (2.0.22-1.1ubuntu2.1) 설정하는 중입니다 ...
openipmi (2.0.22-1.1ubuntu2.1) 설정하는 중입니다 ...
ipmitool (1.8.18-5ubuntu0.1) 설정하는 중입니다 ...
Job for ipmievd.service failed because the control process exited with error code.
See "systemctl status ipmievd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript ipmievd, action "start" failed.
● ipmievd.service - IPMI event daemon
   Loaded: loaded (/lib/systemd/system/ipmievd.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2020-09-25 09:58:54 KST; 9ms ago
  Process: 6933 ExecStart=/usr/sbin/ipmievd $IPMIEVD_OPTIONS (code=exited, status=1/FAILURE)

 9월 25 09:58:54 minigram systemd[1]: Starting IPMI event daemon...
 9월 25 09:58:54 minigram ipmievd[6933]: Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No such file or directory
 9월 25 09:58:54 minigram systemd[1]: ipmievd.service: Control process exited, code=exited status=1
 9월 25 09:58:54 minigram systemd[1]: ipmievd.service: Failed with result 'exit-code'.
 9월 25 09:58:54 minigram systemd[1]: Failed to start IPMI event daemon.
Unable to start ipmievd during installation.  Trying to disable.
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Processing triggers for systemd (237-3ubuntu10.42) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
ureadahead will be reprofiled on next reboot
Processing triggers for install-info (6.5.0.dfsg.1-2) ...

[링크 : http://hpcadmin.tistory.com/61]

 

+

/dev/impi가 필요 하다고.

[링크 : https://lascrea.tistory.com/57]

 

해도 안올라오는데요 ㅠㅠ

[링크 : https://serverfault.com/questions/480371/ipmitool-cant-find-dev-ipmi0-or-dev-ipmidev-0]

 

Posted by 구차니