This sample demonstrates how to read various volume characteristics, including its type (NSS/TFS) and compression status (enabled/disabled) via NCP calls.
#include <errno.h>
#include <nit/nwdir.h>
#include <nwconn.h>
#include <nwerrno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( int argc, char* argv[]) {
int volumeNumber;
#include <npackon.h> /* don't move this directive to a different location */
struct GetVolumeInformationLevel1RequestPacket {
unsigned short SubFuncStrucLen;
unsigned char SubFuncCode;
unsigned long VolumeNumber;
unsigned long InfoLevelNumber;
} req;
struct GetVolumeInformationLevel1ReplyPacket {
unsigned long CurrentServerTime;
unsigned char VConsoleVersion;
unsigned char VConsoleRevision;
unsigned short reserved;
unsigned long InfoLevel;
/* VolInfoDef: */
unsigned long VolumeType;
unsigned long StatusFlagBits;
unsigned long SectorSize;
unsigned long SectorsPerCluster;
unsigned long VolumeSizeInClusters;
unsigned long FreedClusters;
unsigned long SubAllocFreeableClusters;
unsigned long FreeableLimboSectors;
unsigned long NonFreeableLimboSectors;
unsigned long NonFreeableAvailableSubAllocSectors;
unsigned long NonUsableSubAllocSectors;
unsigned long SubAllocClusters;
unsigned long DataStreamsCount;
unsigned long LimboDataStreamsCount;
unsigned long OldestDeletedFileAgeInTicks;
unsigned long CompressedDataStreamsCount;
unsigned long CompressedLimboDataStreamsCount;
unsigned long UnCompressedDataStreamsCount;
unsigned long PreCompressedSectors;
unsigned long CompressedSectors;
unsigned long MigratedFiles;
unsigned long MigratedSectors;
unsigned long ClustersUsedByFAT;
unsigned long ClustersUsedByDirectories;
unsigned long ClustersUsedByExtendedDirectories;
unsigned long TotalDirectoryEntries;
unsigned long UnusedDirectoryEntries;
unsigned long TotalExtendedDirectoryExtants;
unsigned long UnUsedExtendedDirectoryExtants;
unsigned long ExtendedAttributesDefined;
unsigned long ExtendedAttributeExtantsUsed;
unsigned long DirectoryServicesObjectID;
unsigned long VolumeLastModifiedDateAndTime;
} rep;
#include <npackoff.h> /* don't move this directive to a different location */
int ccode;
if ( argc != 2) {
printf( "Usage: %s <vol_name>\n", argv[ 0]);
return EXIT_FAILURE;
}
if ( GetVolumeNumber( argv[ 1], &volumeNumber) != 0) {
printf( "GetVolumeNumber failed, errno = %d (%s), NetWareErrno = %d\n", errno, strerror( errno), NetWareErrno);
return EXIT_FAILURE;
}
printf( "volumeNumber = %d\n", volumeNumber);
req.SubFuncStrucLen = 0x900; /* Hi-Lo */
req.SubFuncCode = 34;
req.VolumeNumber = ( LONG) volumeNumber;
req.InfoLevelNumber = 1;
ccode = NWNCPSend( 123, &req, sizeof( req), &rep, sizeof( rep));
if ( ccode != ESUCCESS) {
printf( "NWNCPSend failed, ccode = %d\n", ccode);
return EXIT_FAILURE;
}
puts( rep.StatusFlagBits & 2 ? "compression enabled" : "compression not enabled");
puts( rep.StatusFlagBits & 0x80000000 ? "NSS" : "traditional");
return EXIT_SUCCESS;
}
© 2008 Novell, Inc. All Rights Reserved.