1*8269e767SBrooks Davis.\" Copyright (c) 2013 The FreeBSD Foundation 2*8269e767SBrooks Davis.\" 3*8269e767SBrooks Davis.\" This documentation was written by Pawel Jakub Dawidek under sponsorship from 4*8269e767SBrooks Davis.\" the FreeBSD Foundation. 5*8269e767SBrooks Davis.\" 6*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 7*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions 8*8269e767SBrooks Davis.\" are met: 9*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 10*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer. 11*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 12*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer in the 13*8269e767SBrooks Davis.\" documentation and/or other materials provided with the distribution. 14*8269e767SBrooks Davis.\" 15*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 16*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*8269e767SBrooks Davis.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 19*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25*8269e767SBrooks Davis.\" SUCH DAMAGE. 26*8269e767SBrooks Davis.\" 27*8269e767SBrooks Davis.Dd February 13, 2013 28*8269e767SBrooks Davis.Dt BINDAT 2 29*8269e767SBrooks Davis.Os 30*8269e767SBrooks Davis.Sh NAME 31*8269e767SBrooks Davis.Nm bindat 32*8269e767SBrooks Davis.Nd assign a local protocol address to a socket 33*8269e767SBrooks Davis.Sh LIBRARY 34*8269e767SBrooks Davis.Lb libc 35*8269e767SBrooks Davis.Sh SYNOPSIS 36*8269e767SBrooks Davis.In sys/types.h 37*8269e767SBrooks Davis.In sys/socket.h 38*8269e767SBrooks Davis.Pp 39*8269e767SBrooks Davis.In fcntl.h 40*8269e767SBrooks Davis.Ft int 41*8269e767SBrooks Davis.Fn bindat "int fd" "int s" "const struct sockaddr *addr" "socklen_t addrlen" 42*8269e767SBrooks Davis.Sh DESCRIPTION 43*8269e767SBrooks DavisThe 44*8269e767SBrooks Davis.Fn bindat 45*8269e767SBrooks Davissystem call assigns the local protocol address to a socket. 46*8269e767SBrooks DavisWhen passed the special value 47*8269e767SBrooks Davis.Dv AT_FDCWD 48*8269e767SBrooks Davisin the 49*8269e767SBrooks Davis.Fa fd 50*8269e767SBrooks Davisparameter, the behavior is identical to a call to 51*8269e767SBrooks Davis.Xr bind 2 . 52*8269e767SBrooks DavisOtherwise, 53*8269e767SBrooks Davis.Fn bindat 54*8269e767SBrooks Davisworks like the 55*8269e767SBrooks Davis.Xr bind 2 56*8269e767SBrooks Davissystem call with two exceptions: 57*8269e767SBrooks Davis.Pp 58*8269e767SBrooks Davis.Bl -enum -offset indent -compact 59*8269e767SBrooks Davis.It 60*8269e767SBrooks DavisIt is limited to sockets in the PF_LOCAL domain. 61*8269e767SBrooks Davis.Pp 62*8269e767SBrooks Davis.It 63*8269e767SBrooks DavisIf the file path stored in the 64*8269e767SBrooks Davis.Fa sun_path 65*8269e767SBrooks Davisfield of the sockaddr_un structure is a relative path, it is located relative 66*8269e767SBrooks Davisto the directory associated with the file descriptor 67*8269e767SBrooks Davis.Fa fd . 68*8269e767SBrooks Davis.El 69*8269e767SBrooks Davis.Sh RETURN VALUES 70*8269e767SBrooks Davis.Rv -std bindat 71*8269e767SBrooks Davis.Sh ERRORS 72*8269e767SBrooks DavisThe 73*8269e767SBrooks Davis.Fn bindat 74*8269e767SBrooks Davissystem call may fail with the same errors as the 75*8269e767SBrooks Davis.Xr bind 2 76*8269e767SBrooks Davissystem call or with the following errors: 77*8269e767SBrooks Davis.Bl -tag -width Er 78*8269e767SBrooks Davis.It Bq Er EBADF 79*8269e767SBrooks DavisThe 80*8269e767SBrooks Davis.Fa sun_path 81*8269e767SBrooks Davisfield does not specify an absolute path and the 82*8269e767SBrooks Davis.Fa fd 83*8269e767SBrooks Davisargument is neither 84*8269e767SBrooks Davis.Dv AT_FDCWD 85*8269e767SBrooks Davisnor a valid file descriptor. 86*8269e767SBrooks Davis.It Bq Er ENOTDIR 87*8269e767SBrooks DavisThe 88*8269e767SBrooks Davis.Fa sun_path 89*8269e767SBrooks Davisfield is not an absolute path and 90*8269e767SBrooks Davis.Fa fd 91*8269e767SBrooks Davisis neither 92*8269e767SBrooks Davis.Dv AT_FDCWD 93*8269e767SBrooks Davisnor a file descriptor associated with a directory. 94*8269e767SBrooks Davis.El 95*8269e767SBrooks Davis.Sh SEE ALSO 96*8269e767SBrooks Davis.Xr bind 2 , 97*8269e767SBrooks Davis.Xr connectat 2 , 98*8269e767SBrooks Davis.Xr socket 2 , 99*8269e767SBrooks Davis.Xr unix 4 100*8269e767SBrooks Davis.Sh AUTHORS 101*8269e767SBrooks DavisThe 102*8269e767SBrooks Davis.Nm 103*8269e767SBrooks Daviswas developed by 104*8269e767SBrooks Davis.An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net 105*8269e767SBrooks Davisunder sponsorship from the FreeBSD Foundation. 106