nfs-ganesha 1.4

cmd_tools.h

Go to the documentation of this file.
00001 
00056 #ifndef _CMD_TOOLS_H
00057 #define _CMD_TOOLS_H
00058 
00059 #ifdef _LINUX
00060 #include <stddef.h>
00061 #endif
00062 
00063 #ifdef _APPLE
00064 #include <stddef.h>
00065 #endif
00066 
00067 #ifdef _SOLARIS
00068 #include "solaris_port.h"
00069 #endif
00070 
00071 #include "fsal.h"
00072 #include <time.h>
00073 
00074 #ifdef _SOLARIS
00075 #ifndef offsetof
00076 #define offsetof(type, member) ( (int) & ((type*)0) -> member )
00077 #endif
00078 #endif
00079 
00080 /* thread-safe and PORTABLE version of localtime... */
00081 struct tm *Localtime_r(const time_t * p_time, struct tm *p_tm);
00082 
00092 int my_atoi(char *str);
00093 
00103 int atomode(char *str);
00104 
00105 int ato64(char *str, unsigned long long *out64);
00106 
00107 time_t atotime(char *str);
00108 char *time2str(time_t time_in, char *str_out);
00109 
00119 void split_path(char *in_path, char **p_path, char **p_file);
00120 
00131 void clean_path(char *str, int len);
00132 
00143 char *concat(char *str1, char *str2, size_t max_len);
00144 
00154 void print_fsal_status(FILE * output, fsal_status_t status);
00155 
00165 void fsal_status_to_string(char * output, fsal_status_t status);
00166 
00175 void print_fsal_attrib_mask(fsal_attrib_mask_t mask, FILE * output);
00176 
00184 char *strtype(fsal_nodetype_t type);
00185 
00194 void print_fsal_attributes(fsal_attrib_list_t attrs, FILE * output);
00195 
00208 void print_item_line(FILE * out, fsal_attrib_list_t * attrib, char *name, char *target);
00209 
00210 /*
00211  * Thoses structures are used to handle FSAL attributes.
00212  */
00213 
00215 typedef enum shell_attr_type__
00216 {
00217 
00218   ATTR_NONE = 0,                /* this special value is used
00219                                    to indicate the end of the attribute list */
00220 
00221   ATTR_32,                      /* 32 bits attribute */
00222   ATTR_64,                      /* 64 bits attribute */
00223   ATTR_OCTAL,                   /* octal number attribute */
00224   ATTR_TIME                     /* YYYYMMDDhhmmss attribute */
00225 } shell_attr_type_t;
00226 
00228 typedef struct shell_attribute__
00229 {
00230 
00231   char *attr_name;              /* name of the attribute. */
00232   shell_attr_type_t attr_type;  /* type of the attribute. */
00233   fsal_attrib_mask_t attr_mask; /* fsal mask constant */
00234   unsigned long int attr_offset;        /* fsal field offset */
00235 
00236 } shell_attribute_t;
00237 
00241 static shell_attribute_t __attribute__ ((__unused__)) shell_attr_list[] =
00242 {
00243   {
00244   "SIZE", ATTR_64, FSAL_ATTR_SIZE, offsetof(fsal_attrib_list_t, filesize)},
00245   {
00246   "MODE", ATTR_OCTAL, FSAL_ATTR_MODE, offsetof(fsal_attrib_list_t, mode)},
00247   {
00248   "OWNER", ATTR_32, FSAL_ATTR_OWNER, offsetof(fsal_attrib_list_t, owner)},
00249   {
00250   "GROUP", ATTR_32, FSAL_ATTR_GROUP, offsetof(fsal_attrib_list_t, group)},
00251   {
00252   "ATIME", ATTR_TIME, FSAL_ATTR_ATIME, offsetof(fsal_attrib_list_t, atime)},
00253   {
00254   "CTIME", ATTR_TIME, FSAL_ATTR_CTIME, offsetof(fsal_attrib_list_t, ctime)},
00255   {
00256   "MTIME", ATTR_TIME, FSAL_ATTR_MTIME, offsetof(fsal_attrib_list_t, mtime)},
00257       /* end of the list */
00258   {
00259   NULL, ATTR_NONE, 0, 0}
00260 
00261 };
00262 
00269 int MkFSALSetAttrStruct(char *attribute_list, fsal_attrib_list_t * fsal_set_attr_struct);
00270 
00271 /* Time diffing function */
00272 struct timeval time_diff(struct timeval time_from, struct timeval time_to);
00273 
00274 /* Timeval printing function */
00275 #define print_timeval(out,_tv_) fprintf(out,"%ld.%.6ld s\n",_tv_.tv_sec,_tv_.tv_usec)
00276 
00277 int getugroups(int maxcount, gid_t * grouplist, char *username, gid_t gid);
00278 
00279 #endif