I am having some difficulty with the VIOC_AFS_SYSNAME call in pioctl. I am
hoping that someone can help me understand what I am doing wrong in the
following code. I have successfully compiled and linked this code. The
problem is that I am always getting an empty string for "sysname" (on both
Solaris and SunOS.) Using truss, I have determined that I am making the
same syscall as 'fs sysname', except that the address of the structure being
passed (afsparams, in this case) is obviously different. The pioctl() returns
0, indicating success. The similar code for VIOC_GET_WSCELL is working
perfectly.
Therefore I presume that I am doing something incorrect in my setup of this
structure when I make the call, or that I am interepreting the the returned
values incorrectly. Any advice anyone can give would be very greatly
appreciated. I was unable to find any sample code that actually uses this
particular pioctl call to use as a sample.
Thanks
-- Garrett D'Amore, QUALCOMM UNIX SysAdmin Team
[EMAIL PROTECTED]
----> BEGIN CODE <----
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <afs/stds.h>
#include <afs/afs.h>
#include <afs/afsint.h>
#include <afs/vice.h>
#include <afs/venus.h>
/* hack to fix bug in AFS headers */
#define V 'V'
#if 0
#include <afs/param.h>
#include <afs/afs_stats.h>
#include <afs/venus.h>
#endif
int main()
{
struct ViceIoctl afsparams;
int result;
int32 zero = (long) 0;
int32 one = (long) 1;
char sysname [ MAXSYSNAME + 1 ] = "Garrett";
afsparams.in = (caddr_t) &zero;
afsparams.in_size = sizeof(zero);
afsparams.out = sysname;
afsparams.out_size = MAXSYSNAME;
result = pioctl(NULL, VIOC_AFS_SYSNAME, &afsparams, 0);
printf("result = %d, sysname = %s\n", result, sysname);
afsparams.out = sysname; /* really cellname */
afsparams.out_size = MAXSYSNAME;
afsparams.in_size = 0;
afsparams.in = NULL;
result = pioctl(NULL, VIOC_GET_WS_CELL, &afsparams, 0);
printf("result = %d, cellname = %s\n", result, sysname);
}
----> END CODE <----