00001
00002 /*---------------------------------------------------------------------------
00003 E.S.O.
00004 ----------------------------------------------------------------------------
00005 File name : filesys.h
00006 Author : N. Devillard
00007 Created on : July 1998
00008 Language : ANSI C
00009 Part of ECLIPSE library for Adonis
00010 Description : file system info utilities
00011 *--------------------------------------------------------------------------*/
00012
00013 /*
00014
00015 $Id: filesys.h,v 1.1 2003/09/03 12:50:47 amodigli Exp $
00016 $Author: amodigli $
00017 $Date: 2003/09/03 12:50:47 $
00018 $Revision: 1.1 $
00019
00020 */
00021
00022 #ifndef _ECLIPSE_FILESYS_H_
00023 #define _ECLIPSE_FILESYS_H_
00024
00025 /*---------------------------------------------------------------------------
00026 Includes
00027 ---------------------------------------------------------------------------*/
00028
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031 #include <string.h>
00032 #include <sys/types.h>
00033 #include <sys/stat.h>
00034 #include <unistd.h>
00035
00036
00037 #define DF_CMD "df -k"
00038
00039 #ifdef _HPUX_SOURCE
00040 #undef DF_CMD
00041 #define DF_CMD "bdf"
00042 #endif
00043
00044 typedef struct _DISK_INFO_ {
00045 char filesystem[256] ;
00046 unsigned long kbytes ;
00047 unsigned long used ;
00048 unsigned long avail ;
00049 int capacity ;
00050 char path[256] ;
00051 } disk_info ;
00052
00053
00054
00055 /*---------------------------------------------------------------------------
00056 Function codes
00057 ---------------------------------------------------------------------------*/
00058
00059
00060 /*---------------------------------------------------------------------------
00061 Function : test_write_permission()
00062 In : path
00063 Out : int: 0 or 1
00064 Job : find out if the current user has write permission on the
00065 provided path.
00066 Notice :
00067 ---------------------------------------------------------------------------*/
00068
00069
00070 int test_write_permission(char * path);
00071
00072
00073
00074
00075 /*---------------------------------------------------------------------------
00076 Function : get_avail_kbytes()
00077 In : path
00078 Out : unsigned long
00079 Job : find out how many kbytes are available on the path
00080 Notice : outsourced to 'df' or 'bdf'
00081 ---------------------------------------------------------------------------*/
00082
00083
00084 unsigned long get_avail_kbytes(char * path);
00085
00086
00087
00088 /*---------------------------------------------------------------------------
00089 Function : get_disk_list()
00090 In : (empty) disk info pointer, number of filesystems found
00091 Out : int 0 if Ok, anything else otherwise
00092 Job : builds up a list of available filesystems on the current
00093 host.
00094 Notice : outsourced to 'df' or 'bdf'
00095 ---------------------------------------------------------------------------*/
00096
00097
00098
00099 int get_disk_list(disk_info ** dlist, int * ndisks);
00100
00101
00102
00103
00104 /*---------------------------------------------------------------------------
00105 Function : print_disk_list()
00106 In : disk info list, number of filesystems on the current host
00107 Out : void
00108 Job : print out a la 'df' or 'bdf'
00109 Notice :
00110 ---------------------------------------------------------------------------*/
00111
00112 void print_disk_list(disk_info * dlist, int ndisks);
00113
00114
00115
00116 /*---------------------------------------------------------------------------
00117 Function : sort_disks_by_dec_avail()
00118 In : two pointers to allocated disk_info structs
00119 Out : int 1 if d1->avail < d2->avail, -1 otherwise
00120 Job : qsort helper function to sort out disk_info structs
00121 Notice : only useful to qsort
00122 ---------------------------------------------------------------------------*/
00123
00124
00125 int sort_disks_by_dec_avail(const void * d1, const void *d2);
00126
00127
00128 #endif
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001