Re: iDisk access in Cocoa
Re: iDisk access in Cocoa
- Subject: Re: iDisk access in Cocoa
- From: Andrew Mortensen <email@hidden>
- Date: Tue, 19 Feb 2002 10:50:46 -0500 (EST)
He meant statfs, not fstat. You might be able to determine some things
about the filesystem from the inode, but the information returned by
statfs would be much more useful.
Here's a simple program that gets information for all mounted disks:
/* get and display file system information */
#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <unistd.h>
#include <dirent.h>
#include <pwd.h>
static void
fsinfodisplay( struct statfs stfs )
{
struct passwd *pw;
if (( pw = getpwuid( stfs.f_owner )) == NULL ) {
printf( "\tFile system owner: \t\t%u\n", stfs.f_owner );
} else {
printf( "\tFile system owner: \t\t%s (UID: %u)\n", pw->pw_name,
stfs.f_owner );
}
printf( "\tFile system type: \t\t%s\n", stfs.f_fstypename );
printf( "\tFile system mounted at: \t%s\n", stfs.f_mntonname );
printf( "\tFile system device mounted: \t%s\n", stfs.f_mntfromname );
}
int
main( int argc, char *argv[] )
{
DIR *dirp;
int i;
struct statfs stfs;
struct dirent *direntp;
if ( argc == 1 ) {
if ( statfs( "/", &stfs ) != 0 ) {
perror( "statfs" );
exit( 1 );
}
printf( "File system info for /:\n\n" );
fsinfodisplay( stfs );
if (( dirp = opendir( "/Volumes" )) == NULL ) {
perror( "/Volumes" );
exit( 1 );
}
if ( chdir( "/Volumes" ) != 0 ) {
perror( "/Volumes" );
exit( 1 );
}
while (( direntp = readdir( dirp )) != NULL ) {
if ( direntp->d_name[ 0 ] != '.' ) {
if ( statfs( direntp->d_name, &stfs ) != 0 ) {
perror( "statfs" );
exit( 1 );
}
printf( "\nFile system info for %s:\n", direntp->d_name );
fsinfodisplay( stfs );
}
}
if ( closedir( dirp ) < 0 ) {
perror( "closedir" );
exit( 1 );
}
} else {
for ( i = 1; i < argc; i++ ) {
if ( statfs( argv[ i ], &stfs ) != 0 ) {
perror( "statfs" );
exit( 1 );
}
printf( "File system info for %s:\n", argv[ i ] );
fsinfodisplay( stfs );
if ( argc > 2 && i != ( argc - 1 )) {
printf( "\n" );
}
}
}
exit( 0 );
}
On Tue, 19 Feb 2002, M Ramachandra Acharya wrote:
>
Hi Vince
>
>
>> But when I use finder and check the properties of the volume by selecting
>
>> it
>
>> and pressing 'Command + I', the info widow says that the 'Format' is
>
>> 'WebDAV'. I thought of using this as the unique key, but alas! could not
>
>> find any function to get this info.
>
>
>
>
>
> What you can do is use the fstat function
>
>
>
> ib the structure it returns is the file sysyem type.
>
>
>
>
I just tried this. I use the function 'fstat' defined in 'stat.h'.
>
It fills in a structure which has lot many fields defined (struct stat).
>
>
To me it appeared that I can use the "st_ino" field of this structure. It is
>
the inode's number for the file. After doing some tests, I found that for
>
iDisk, it remains 3 and for any other volumes (local, network, CD ROM,
>
volumes mounted from my laptop in FireWire mode) it remains 2.
>
>
Is this how I should be doing it or do you think I should treat the
>
structure in a different way. Actually I am not sure about this field. Can
>
you pl. point me to some documents which might explain these fields in
>
detail?
>
>
TIA
>
>
With regards
>
>
Ram
>
>
>
--------------------------------------------------------------
>
Robosoft Technologies, Mangalore, India
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.