/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* Client-side interface to the IO Daemon (IOD)
*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <libintl.h>
#include <door.h>
#include <sys/byteorder.h>
#include <smb/ntstatus.h>
#include "smbfs_lib.h"
#include "smbfs_nb_lib.h"
#include <assert.h>
#include "smbfs_charsets.h"
#include "smbfs_private.h"
/*
* This is constant for the life of a process,
* and initialized at startup, so no locks.
*/
char *
smbfs_iod_door_path(void)
{
int x;
if (door_path[0] == '\0') {
}
return (door_path);
}
/*
* Open the door (client side) and
* find out if the service is there.
*/
int
{
char *path;
int err = 0;
path = smbfs_iod_door_path();
if (fd < 0)
return (errno);
/*
* Make sure the IOD is running.
* Pass NULL args.
*/
if (rc < 0) {
return (err);
}
}
/* This handle controls per-process resources. */
return (0);
}
/*
* Get a door handle to the IOD, starting it if necessary.
* On success, sets ctx->ct_door_fd
*/
int
{
if (--tmo <= 0)
goto errout;
/*
* We have no per-user IOD yet. Request one.
* Do this request every time through the loop
* because the master IOD will only start our
* per-user IOD if we don't have one, and our
* first requst could have happened while we
* had an IOD that was doing shutdown.
*/
err = smbfs_iod_start();
if (err != 0)
goto errout;
/*
* Wait for it to get ready.
*/
(void) sleep(1);
}
/* Save the door fd. */
return (0);
"Could not contact service: %s"),
return (ENOTACTIVE);
}
/*
* Ask the IOD to connect using the info in ctx.
* Called by newvc.
*/
int
{
int err = 0;
/* Should already have the IOD door. */
if (ctx->ct_door_fd < 0)
return (EINVAL);
return (err);
}
return (err);
}
/*
* Functions called by the IO deamon (IOD).
* Here in the library to simplify testing.
* Be the reader thread for this VC.
*/
int
{
/* Calle should have opened these */
goto out;
}
/*
* This is the reader / reconnect loop.
*
* We could start with state "idle", but
* we know someone wants a connection to
* this server, so start in "vcactive".
*
* XXX: Add some syslog calls in here?
*/
for (;;) {
switch (vcst) {
case SMBIOD_ST_IDLE:
/*
* Wait for driver requests to arrive
* for this VC, then return here.
* Next state is normally RECONNECT.
*/
DPRINT("state: idle");
goto out;
}
continue;
case SMBIOD_ST_RECONNECT:
DPRINT("state: reconnect");
if (err == 0) {
continue;
}
/*
* If the error was EAUTH, retry is
* not likely to succeed either, so
* just exit this thread. The user
* will need to run smbutil to get
* a new thread with new auth info.
*/
goto out;
continue;
case SMBIOD_ST_RCFAILED:
DPRINT("state: rcfailed");
/*
* Reconnect failed. Kill off any
* requests waiting in the driver,
* then get ready to try again.
* Next state is normally IDLE.
*/
goto out;
}
continue;
case SMBIOD_ST_VCACTIVE:
DPRINT("state: active");
goto out;
}
continue;
case SMBIOD_ST_DEAD:
DPRINT("state: dead");
err = 0;
goto out;
default:
goto out;
}
}
out:
}
}
return (err);
}