netstat 명령어에서 path에 @가 무슨의미인지...

hypnosis의 이미지

UDS 를 보다가 netstat 명령어로 뭐가 connect 됐는지 확인해 볼려고 했는데요

보다보면 Path에 @/org/kernel/udev/udevd 등등 앞에 @가 붙어있는 path명이

몇개 있는데 이 @가 의미 하는게 뭔지 잘 몰라서.. 이렇게 물어봅니다 ~

아시는분 명쾌한 해답좀 ㅠㅠ 부탁드려요~

ymir의 이미지

http://blog.siphos.be/2011/12/unix-domain-sockets-are-files/

Quote:

■ Linux supports an abstract namespace for sockets, so not all of these are actually bound/connected to a file.
Instead, they connect to a “name” instead, which cannot be traced back to a file.
For those interested, looking at /proc/net/unix or netstat -xa shows the abstract ones starting with an @ sign.

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

hypnosis의 이미지

독해를 잘 못하는 저로써는.. 그냥 보면 일단 추상적인 네임스페이스로 사용되는것 같은데....

파일은 존재하지 않고 그냥 @붙인 파일이름으로 사용하는 것인지...

정확하게 모르겠더라구요...

인터넷에 있는 일반적인 테스트용 소스로 @붙여서 실행하면 그냥 ㅍㅏ일이 생기는것이고..

어떻게 써야 되는건지...

ymir의 이미지

unix domain socket 을 쓸 때, 실제 파일 경로를 사용하지 않아도 된다는 뜻입니다.
이 경우에는, 그냥 파일이 아닌 그냥 이름(name) 으로 취급되는데.. (abstract domain socket)
/proc/net/unix 파일을 열어 보거나, netstat 명령으로 봤을 때, 파일명 앞에 @를 붙여서 구별해 준다는 뜻이죠.

쓰는 방법은 sockaddr_un 구조체의 sun_path 에서 첫번째 바이트를 '\0' 으로 넣어주고, 그 뒤에 파일의 경로를 적어 주면 됩니다.

    struct sockaddr_un serveraddr;
 
    bzero(&serveraddr, sizeof(serveraddr));
    serveraddr.sun_family = AF_UNIX;
    serveraddr.sun_path[0] = '\0';
    strcpy(&serveraddr.sun_path[1], "/path/to/non-exist");
 
    ret = bind(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr));
    ...

그럼 다음과 같이 표시되죠.

$ netstat -anp | grep a.out
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
unix  2      [ ]         DGRAM                    189653   3374/a.out          @/path/to/non-exist

unix(7) 의 man page 에서 Address Format 섹션의 abstract 부분을 보세요. (man -7 unix)

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

hypnosis의 이미지

정말 감사합니다!! ㅠㅠ 이렇게 명쾌한 해답을 ..

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.