本文整理汇总了C++中pioctl函数的典型用法代码示例。如果您正苦于以下问题:C++ pioctl函数的具体用法?C++ pioctl怎么用?C++ pioctl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pioctl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fs_getfilecachestats
int
fs_getfilecachestats(afs_uint32 * max_bytes, afs_uint32 * used_bytes,
afs_uint32 * max_vnodes, afs_uint32 * used_vnodes)
{
afs_uint32 parms[16];
struct ViceIoctl a_params;
a_params.in_size = 0;
a_params.out_size = sizeof(parms);
a_params.in = NULL;
a_params.out = (char *)parms;
memset(parms, 0, sizeof(parms));
if (pioctl(NULL, VIOCGETCACHEPARAMS, &a_params, 0) == -1)
return errno;
/* param[0] and param[1] send maxbytes and usedbytes in kbytes */
if (max_vnodes)
*max_vnodes = parms[2];
if (used_vnodes)
*used_vnodes = parms[3];
if (max_bytes)
*max_bytes = parms[4];
if (used_bytes)
*used_bytes = parms[5];
return 0;
}
示例2: LOG1
int CIFVideoNode::stop(bool keepBuffers)
{
LOG1("@%s: device = %s", __FUNCTION__, mName.string());
int ret = 0;
// Always stream off because of driver feature.
// Driver will only turn JPEG encoding off in the streamoff.
enum v4l2_buf_type type = mInBufType;
ret = pioctl(mFd, VIDIOC_STREAMOFF, &type);
if (ret < 0) {
LOGE("VIDIOC_STREAMOFF returned: %d (%s)", ret, strerror(errno));
return ret;
}
mState = DEVICE_PREPARED;
if (mState == DEVICE_PREPARED) {
if (!keepBuffers) {
destroyBufferPool();
mState = DEVICE_CONFIGURED;
}
} else {
LOGW("Trying to stop a device not started");
ret = -1;
}
mBuffersInDevice = 0;
return ret;
}
示例3: debug
static int
debug(int pioctl_cmd, int inflags, int *outflags, char *pathname)
{
struct ViceIoctl a_params;
afs_int32 rinflags = inflags;
afs_int32 routflags;
if (inflags != -1) {
a_params.in_size = sizeof(rinflags);
a_params.in = (char *)&rinflags;
} else {
a_params.in_size = 0;
a_params.in = NULL;
}
if (outflags) {
a_params.out_size = sizeof(routflags);
a_params.out = (char *)&routflags;
} else {
a_params.out_size = 0;
a_params.out = NULL;
}
if (pioctl(pathname, pioctl_cmd, &a_params, 0) == -1)
return errno;
if (outflags)
*outflags = routflags;
return 0;
}
示例4: NFSUnlog
static int
NFSUnlog(afs_int32 ahost, afs_int32 auid)
{
afs_int32 code;
afs_int32 pheader[6];
char space[1200];
struct ViceIoctl blob;
/* otherwise we've got the token, now prepare to build the pioctl args */
pheader[0] = ahost;
pheader[1] = auid;
pheader[2] = 0; /* group low */
pheader[3] = 0; /* group high */
pheader[4] = 9; /* unlog pioctl index */
pheader[5] = 1; /* NFS protocol exporter # */
/* copy stuff in */
memcpy(space, pheader, sizeof(pheader));
/* finally setup the pioctl call's parameters */
blob.in_size = sizeof(pheader);
blob.in = space;
blob.out_size = 0;
blob.out = NULL;
code = pioctl(NULL, _VICEIOCTL(99), &blob, 0);
if (code) {
code = errno;
}
return code;
}
示例5: fhb_fhget
static void
fhb_fhget(char *filename, struct fhb_handle *handle)
{
int ret = 0;
#if defined(HAVE_GETFH) && defined(HAVE_FHOPEN)
{
fhandle_t fh;
ret = getfh(filename, &fh);
if (ret)
err(1, "getfh");
memcpy(handle, &fh, sizeof(fh));
}
#endif
{
struct ViceIoctl vice_ioctl;
vice_ioctl.in = NULL;
vice_ioctl.in_size = 0;
vice_ioctl.out = (caddr_t) handle;
vice_ioctl.out_size = sizeof(*handle);
ret = pioctl(filename, VIOC_FHGET, &vice_ioctl, 0);
if (ret)
errx(1, "k_pioctl");
}
}
示例6: Config_SetSysName
BOOL Config_SetSysName (LPCTSTR pszName, ULONG *pStatus)
{
BOOL rc = TRUE;
ULONG status = 0;
if (Config_GetServiceState() == SERVICE_RUNNING)
{
struct {
ULONG cbData;
TCHAR szData[ PIOCTL_MAXSIZE ];
} InData;
memset (&InData, 0x00, sizeof(InData));
USHORT i=0, j=0, len=lstrlen(pszName);
if ( len == 0 ) {
Message (MB_ICONHAND, GetErrorTitle(), IDS_FAILCONFIG_SYSNAME, TEXT("A sysname must be specified"));
return(-1);
}
while ( pszName[i] ) {
if ( !isspace(pszName[i]) ) {
InData.szData[j++] = pszName[i];
} else if (InData.szData[j-1] != '\0') {
InData.szData[j++] = '\0';
InData.cbData++;
}
i++;
}
InData.szData[j++] = '\0';
InData.cbData++; /* one word */
BYTE OutData[ PIOCTL_MAXSIZE ];
memset (OutData, 0x00, sizeof(OutData));
struct ViceIoctl IOInfo;
IOInfo.in_size = sizeof(ULONG) + j;
IOInfo.in = (char *)&InData;
IOInfo.out = (char *)OutData;
IOInfo.out_size = PIOCTL_MAXSIZE;
if ((status = pioctl (0, VIOC_AFS_SYSNAME, &IOInfo, 1)) != 0)
{
rc = FALSE;
}
}
if (rc)
{
Config_WriteGlobalString (TEXT("SysName"), pszName);
}
if (pStatus && !rc)
*pStatus = status;
if (!rc)
Message (MB_ICONHAND, GetErrorTitle(), IDS_FAILCONFIG_SYSNAME, TEXT("%ld"), status);
return rc;
}
示例7: main
int main(int argc, char **argv)
{
ViceFid fid;
char realm[MAXHOSTNAMELEN+1];
char tmpfname[80];
int fd;
struct ViceIoctl vioc;
char space[2048];
int rc;
if (argc != 2) {
fprintf(stderr, "Usage: %s <inc-file-name>\n", argv[0]);
exit(-1);
}
/* make sure object is inconsistent */
if (!IsObjInc(argv[1], &fid, realm)) {
fprintf(stderr, "%s isn't inconsistent\n", argv[1]);
exit(0);
}
/* get fid and make sure it is a file */
if (ISDIR(fid) && !FID_IsLocalDir(&fid)) {
fprintf(stderr, "%s is a directory - must be removed manually\n", argv[1]);
exit(-1);
}
/* create an empty file /tmp/REPAIR.XXXXXX */
strcpy(tmpfname, "/tmp/RMINC.XXXXXX");
if ((fd = mkstemp(tmpfname)) < 0) {
fprintf(stderr, "Couldn't create /tmp file\n");
exit(-1);
}
close(fd);
/* dorepair on the fid with an empty file */
vioc.in_size = (short)(1+strlen(tmpfname));
vioc.in = tmpfname;
vioc.out_size = (short) sizeof(space);
vioc.out = space;
memset(space, 0, (int) sizeof(space));
rc = pioctl(argv[1], _VICEIOCTL(_VIOC_REPAIR), &vioc, 0);
if (rc < 0 && errno != ETOOMANYREFS) {
fprintf(stderr, "Error %d for repair\n", errno);
unlink(tmpfname);
exit(-1);
}
unlink(tmpfname);
/* remove the repaired file */
if (unlink(argv[1])) {
fprintf(stderr, "Couldn't remove %s\n", argv[1]);
exit(-1);
}
exit(0);
}
示例8: afsd_ServicePerformFlushVolumeCmd
/////////////////////////////////////////////////////////////////////
//
// Call routine found in FS.EXE to flush volume.
//
// At entry, input param is UNC string for volume,
// e.g. '\\afs\all\athena.mit.edu\user\m\h\mholiday'
//
// I believe that success from 'pioctl' routine
// indicated by return value of zero (0).
//
afs_int32
afsd_ServicePerformFlushVolumeCmd(char *data)
{
afs_int32 code;
struct ViceIoctl blob;
afsi_log("Flushing Volume \"%s\"",data);
memset(&blob, '\0', sizeof(blob));
code = pioctl(data, VIOC_FLUSHVOLUME, &blob, 0);
return code;
}
示例9: IsObjInc
int IsObjInc(char *name, ViceFid *fid, char *realm)
{
struct GetFid {
ViceFid fid;
ViceVersionVector vv;
char realm[MAXHOSTNAMELEN+1];
} out;
struct ViceIoctl vio;
struct stat statbuf;
char symval[MAXPATHLEN];
int rc, n;
memset(fid, 0, sizeof(ViceFid));
realm[0] = '\0';
/* what if the begin repair has been done already */
rc = stat(name, &statbuf);
if (rc) {
/* is it a sym link */
symval[0] = 0;
rc = readlink(name, symval, MAXPATHLEN);
if (rc < 0) return(0);
/* it's a sym link, alright */
n = sscanf(symval, "@%x.%x.%[email protected]%s",
&fid->Volume, &fid->Vnode, &fid->Unique, realm);
return(n == 4);
}
memset(&out, 0, sizeof(out));
vio.in = NULL;
vio.in_size = 0;
vio.out = (char *)&out;
vio.out_size = sizeof(out);
rc = pioctl(name, _VICEIOCTL(_VIOC_GETFID), &vio, 0);
if (rc < 0 && errno != ETOOMANYREFS) {
fprintf(stderr, "Error %d for Getfid\n", errno);
return(0);
}
memcpy(fid, &out.fid, sizeof(ViceFid));
strcpy(realm, out.realm);
if (!ISDIR(out.fid) && (statbuf.st_mode & S_IFDIR))
return(1);
if (out.vv.StoreId.Host == -1)
return(1);
return(0);
}
示例10: set_acl
static int
set_acl(char *dir)
{
struct ViceIoctl a_params;
char *foo = "1\n0\nsystem:anyuser 0\n";
a_params.in_size = strlen(foo);
a_params.out_size = 0;
a_params.in = foo;
a_params.out = NULL;
return pioctl(dir, VIOCSETAL, &a_params, 1);
}
示例11: fs_wscell
int
fs_wscell(char *cell, size_t cell_sz)
{
struct ViceIoctl a_params;
a_params.in_size = 0;
a_params.in = NULL;
a_params.out_size = cell_sz;
a_params.out = cell;
if (pioctl(NULL, VIOC_GET_WS_CELL, &a_params, 0) < 0)
return errno;
return 0;
}
示例12: Config_GetServerPrefs
PSERVERPREFS Config_GetServerPrefs (BOOL fVLServers)
{
PSERVERPREFS pPrefs = New (SERVERPREFS);
memset (pPrefs, 0x00, sizeof(SERVERPREFS));
pPrefs->fVLServers = fVLServers;
if (Config_GetServiceState() == SERVICE_RUNNING)
{
// We retrieve server prefs in batches--start that loop now.
//
size_t iOut = 0;
for (int iOffset = 0; ; )
{
cm_SPrefRequest_t InData;
memset (&InData, 0x00, sizeof(InData));
InData.offset = iOffset;
InData.flags = (pPrefs->fVLServers) ? CM_SPREF_VLONLY : 0;
InData.num_servers = cSERVERPREFS_CHUNK;
BYTE OutDataStorage[ sizeof(cm_SPrefInfo_t) + cSERVERPREFS_CHUNK * sizeof(cm_SPref_t) ];
memset (OutDataStorage, 0x00, sizeof(OutDataStorage));
cm_SPrefInfo_t *pOutData = (cm_SPrefInfo_t *)OutDataStorage;
struct ViceIoctl IOInfo;
IOInfo.in_size = sizeof(InData);
IOInfo.in = (char *)&InData;
IOInfo.out = (char *)pOutData;
IOInfo.out_size = sizeof(cm_SPrefInfo_t) + cSERVERPREFS_CHUNK * sizeof(cm_SPref_t);
if (pioctl (0, VIOC_GETSPREFS, &IOInfo, 1) != 0)
break;
if (!REALLOC (pPrefs->aPrefs, pPrefs->cPrefs, iOut + pOutData->num_servers, cREALLOC_PREFS))
break;
for (size_t ii = 0; ii < pOutData->num_servers; ++ii)
{
pPrefs->aPrefs[ iOut ].ipServer = pOutData->servers[ ii ].host.s_addr;
pPrefs->aPrefs[ iOut ].iRank = pOutData->servers[ ii ].rank;
iOut ++;
}
if ((iOffset = pOutData->next_offset) == 0)
break;
}
}
return pPrefs;
}
示例13: in_afs
static int
in_afs (char *path)
{
static char space[2048];
struct ViceIoctl vi;
vi.in_size = 0;
vi.out_size = sizeof (space);
vi.out = space;
if (pioctl (path, VIOC_FILE_CELL_NAME, &vi, 1)
&& (errno == EINVAL || errno == ENOENT))
return 0;
return 1;
}
示例14: fs_getfilecellname
int
fs_getfilecellname(char *path, char *cell, size_t len)
{
struct ViceIoctl a_params;
a_params.in_size = 0;
a_params.out_size = len;
a_params.in = NULL;
a_params.out = cell;
if (pioctl(path, VIOC_FILE_CELL_NAME, &a_params, 1) == -1)
return errno;
return 0;
}
示例15: fs_getcrypt
int
fs_getcrypt(afs_uint32 * level)
{
struct ViceIoctl a_params;
a_params.in_size = 0;
a_params.out_size = sizeof(*level);
a_params.in = NULL;
a_params.out = (char *)level;
if (pioctl(NULL, VIOC_GETRXKCRYPT, &a_params, 0) == -1)
return errno;
return 0;
}