/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
*/
/*
* Copyright (c) 2013 Joyent, Inc. All Rights reserved.
*/
#include <limits.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <dirent.h>
#include <ctype.h>
#include <string.h>
#include "libproc.h"
#include "Pcontrol.h"
/*
* Pfdinfo.c - obtain open file information.
*/
/*
* Allocate an fd_info structure and stick it on the list.
* (Unless one already exists.) The list is sorted in
* reverse order. We will traverse it in that order later.
* This makes the usual ordered insert *fast*.
*/
{
int i;
}
return (fip);
}
break;
}
}
return (NULL);
P->num_fd++;
return (fip);
}
/*
* Attempt to load the open file information from a live process.
*/
static void
{
/*
* In the unlikely case there are *no* file descriptors open,
* we will keep rescanning the proc directory, which will be empty.
* This is an edge case it isn't worth adding additional state to
* to eliminate.
*/
if (P->num_fd > 0) {
return;
}
int fd;
/*
* Try to get the path information first.
*/
return;
}
int len;
continue;
}
/* attempt to determine the path to it */
case S_IFDOOR:
case S_IFSOCK:
/* not applicable */
len = -1;
break;
default:
fd);
break;
}
if (len < 0) {
} else {
}
}
}
}
int
{
int rv;
/* Make sure we have live data, if appropriate */
load_fdinfo(P);
/* NB: We walk the list backwards. */
return (rv);
}
return (0);
}