JM プロジェクトは、主に Linux 関連のマニュアルページの日本語ページを翻訳・公開しています。
... path) + strlen(sun_path) + 1 であり、 sun_path にはヌル終端されたパス名が格納される。 (Linux では、上記の offsetof () 式は sizeof(sa_family_t) の値と同じだが、 他の実装では sun_path の前に他のフィールドが含まれる場合もある。 そのため、 offsetof () 式を ... 同様に、 socketpair (2) で作成される 2 つのソケットも名前を持たない。 名前なしのソケットのアドレスを返す際には、 その長さは sizeof(sa_family_t) であり、 sun_path は検査すべきではない。 * abstract (抽象) : 抽象ソケットアドレスは、 sun_path[0] がヌルバイト ... ない)。 この名前はファイルシステムのパス名とは何の関係もない。 抽象ソケットのアドレスを返される際には、 返される addrlen は sizeof(sa_family_t) より大きく (つまり 2 より大きく)、 ソケットの名前は sun_path の最初の (addrlen - sizeof(sa_family_t)) バイトに ... ... ct rtattr *rta; unsigned int mtu = 1000; int rtnetlink_sk = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); memset(&req, 0, sizeof(req)); req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.if)); req.nh.nlmsg_flags = NLM_F_REQUEST; req.nh.nlmsg_type = RTM_NEWLIN ... = (struct rtattr *)(((char *) &req) + NLMSG_ALIGN(req.nh.nlmsg_len)); rta->rta_type = IFLA_MTU; rta->rta_len = RTA_LENGTH(sizeof(mtu)); req.nh.nlmsg_len = NLMSG_ALIGN(req.nh.nlmsg_len) + RTA_LENGTH(sizeof(mtu)); memcpy(RTA_DATA(rta), &mtu, sizeof(mtu) ... ... GN () are constant expressions (assuming their argument is constant), meaning that these values can be used to declare the size of global variables. This may not be portable, however. 例 次のコードは、受け取った補助バッファーから IP_TTL オプションを探す ... R(&msgh, cmsg)) { if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) { memcpy(&receive_ttl, CMSG_DATA(cmsg), sizeof(received_ttl)); break; } } if (cmsg == NULL) { /* Error: IP_TTL not enabled or small buffer or I/O error */ } 以下のコード ... yfds[NUM_FD]; /* Contains the file descriptors to pass */ char iobuf[1]; struct iovec io = { .iov_base = iobuf, .iov_len = sizeof(iobuf) }; union { /* Ancillary data buffer, wrapped in a union in order to ensure it is suitably aligned */ char buf[CMSG_ ... ... GN () are constant expressions (assuming their argument is constant), meaning that these values can be used to declare the size of global variables. This may not be portable, however. 例 次のコードは、受け取った補助バッファーから IP_TTL オプションを探す ... R(&msgh, cmsg)) { if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) { memcpy(&receive_ttl, CMSG_DATA(cmsg), sizeof(received_ttl)); break; } } if (cmsg == NULL) { /* Error: IP_TTL not enabled or small buffer or I/O error */ } 以下のコード ... yfds[NUM_FD]; /* Contains the file descriptors to pass */ char iobuf[1]; struct iovec io = { .iov_base = iobuf, .iov_len = sizeof(iobuf) }; union { /* Ancillary data buffer, wrapped in a union in order to ensure it is suitably aligned */ char buf[CMSG_ ... ... GN () are constant expressions (assuming their argument is constant), meaning that these values can be used to declare the size of global variables. This may not be portable, however. 例 次のコードは、受け取った補助バッファーから IP_TTL オプションを探す ... R(&msgh, cmsg)) { if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) { memcpy(&receive_ttl, CMSG_DATA(cmsg), sizeof(received_ttl)); break; } } if (cmsg == NULL) { /* Error: IP_TTL not enabled or small buffer or I/O error */ } 以下のコード ... yfds[NUM_FD]; /* Contains the file descriptors to pass */ char iobuf[1]; struct iovec io = { .iov_base = iobuf, .iov_len = sizeof(iobuf) }; union { /* Ancillary data buffer, wrapped in a union in order to ensure it is suitably aligned */ char buf[CMSG_ ... ... GN () are constant expressions (assuming their argument is constant), meaning that these values can be used to declare the size of global variables. This may not be portable, however. 例 次のコードは、受け取った補助バッファーから IP_TTL オプションを探す ... R(&msgh, cmsg)) { if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) { memcpy(&receive_ttl, CMSG_DATA(cmsg), sizeof(received_ttl)); break; } } if (cmsg == NULL) { /* Error: IP_TTL not enabled or small buffer or I/O error */ } 以下のコード ... yfds[NUM_FD]; /* Contains the file descriptors to pass */ char iobuf[1]; struct iovec io = { .iov_base = iobuf, .iov_len = sizeof(iobuf) }; union { /* Ancillary data buffer, wrapped in a union in order to ensure it is suitably aligned */ char buf[CMSG_ ... ... GN () are constant expressions (assuming their argument is constant), meaning that these values can be used to declare the size of global variables. This may not be portable, however. 例 次のコードは、受け取った補助バッファーから IP_TTL オプションを探す ... R(&msgh, cmsg)) { if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) { memcpy(&receive_ttl, CMSG_DATA(cmsg), sizeof(received_ttl)); break; } } if (cmsg == NULL) { /* Error: IP_TTL not enabled or small buffer or I/O error */ } 以下のコード ... yfds[NUM_FD]; /* Contains the file descriptors to pass */ char iobuf[1]; struct iovec io = { .iov_base = iobuf, .iov_len = sizeof(iobuf) }; union { /* Ancillary data buffer, wrapped in a union in order to ensure it is suitably aligned */ char buf[CMSG_ ... ... GN () are constant expressions (assuming their argument is constant), meaning that these values can be used to declare the size of global variables. This may not be portable, however. 例 次のコードは、受け取った補助バッファーから IP_TTL オプションを探す ... R(&msgh, cmsg)) { if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) { memcpy(&receive_ttl, CMSG_DATA(cmsg), sizeof(received_ttl)); break; } } if (cmsg == NULL) { /* Error: IP_TTL not enabled or small buffer or I/O error */ } 以下のコード ... yfds[NUM_FD]; /* Contains the file descriptors to pass */ char iobuf[1]; struct iovec io = { .iov_base = iobuf, .iov_len = sizeof(iobuf) }; union { /* Ancillary data buffer, wrapped in a union in order to ensure it is suitably aligned */ char buf[CMSG_ ... ... GN () are constant expressions (assuming their argument is constant), meaning that these values can be used to declare the size of global variables. This may not be portable, however. 例 次のコードは、受け取った補助バッファーから IP_TTL オプションを探す ... R(&msgh, cmsg)) { if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) { memcpy(&receive_ttl, CMSG_DATA(cmsg), sizeof(received_ttl)); break; } } if (cmsg == NULL) { /* Error: IP_TTL not enabled or small buffer or I/O error */ } 以下のコード ... yfds[NUM_FD]; /* Contains the file descriptors to pass */ char iobuf[1]; struct iovec io = { .iov_base = iobuf, .iov_len = sizeof(iobuf) }; union { /* Ancillary data buffer, wrapped in a union in order to ensure it is suitably aligned */ char buf[CMSG_ ... ... t ELF magic: 0x7f454c46 Class: 0x02 プログラムのソース #include < stdio.h > #include < stdlib.h > #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) int main(void) { FILE *fp = fopen("/bin/sh", "rb"); if (!fp) { perror("fopen"); return EXIT_FAILU ... RE; } unsigned char buffer[4]; size_t ret = fread(buffer, ARRAY_SIZE(buffer), sizeof(*buffer), fp); if (ret != sizeof(*buffer)) { fprintf(stderr, "fread() failed: %zu\n", ret); exit(EXIT_FAILURE); } printf(" ... 日本語の文書やマニュアルを配布している個人/プロジェクトへのリンクです。