The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/tests/zfs-tests/cmd/zfs_diff-socket.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * This file and its contents are supplied under the terms of the
    3  * Common Development and Distribution License ("CDDL"), version 1.0.
    4  * You may only use this file in accordance with the terms of version
    5  * 1.0 of the CDDL.
    6  *
    7  * A full copy of the text of the CDDL should have accompanied this
    8  * source.  A copy of the CDDL is also available via the Internet at
    9  * http://www.illumos.org/license/CDDL.
   10  */
   11 
   12 /*
   13  * Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
   14  */
   15 
   16 #include <fcntl.h>
   17 #include <sys/un.h>
   18 #include <sys/socket.h>
   19 #include <sys/stat.h>
   20 #include <sys/types.h>
   21 #include <unistd.h>
   22 #include <errno.h>
   23 #include <stdio.h>
   24 #include <stdlib.h>
   25 #include <string.h>
   26 
   27 int
   28 main(int argc, char *argv[])
   29 {
   30         struct sockaddr_un sock;
   31         int fd;
   32         char *path;
   33         size_t size;
   34         if (argc != 2) {
   35                 fprintf(stderr, "usage: %s /path/to/socket\n", argv[0]);
   36                 exit(1);
   37         }
   38         path = argv[1];
   39         size =  sizeof (sock.sun_path);
   40         (void) snprintf(sock.sun_path, size, "%s", path);
   41 
   42         sock.sun_family = AF_UNIX;
   43         if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) {
   44                 perror("socket");
   45                 return (1);
   46         }
   47         if (bind(fd, (struct sockaddr *)&sock, sizeof (struct sockaddr_un))) {
   48                 perror("bind");
   49                 return (1);
   50         }
   51         if (close(fd)) {
   52                 perror("close");
   53                 return (1);
   54         }
   55         return (0);
   56 }

Cache object: c99de2c42878ccfc7ef493eb174b9347


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.