Whamcloud - gitweb
LU-12678 socklnd: initialize the_ksocklnd at compile-time.
[fs/lustre-release.git] / snmp / lustre-snmp-util.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  */
26 /*
27  * This file is part of Lustre, http://www.lustre.org/
28  * Lustre is a trademark of Sun Microsystems, Inc.
29  *
30  * snmp/lustre-snmp-util.c
31  *
32  * Author: PJ Kirner <pjkirner@clusterfs.com>
33  */
34
35 /*
36  *   include important headers
37  */
38
39 #include <net-snmp/net-snmp-config.h>
40 #include <net-snmp/net-snmp-includes.h>
41 #include <net-snmp/agent/net-snmp-agent-includes.h>
42
43 /*
44  *  include our .h file
45  */ 
46
47 #include <sys/types.h>
48 #include <sys/vfs.h>
49 #include <dirent.h>
50 #include <sys/stat.h>
51 #include <unistd.h>
52 #include <stdio.h>
53 #include <stdarg.h>
54 #include <string.h>
55 #include "lustre-snmp-util.h"
56
57 /*********************************************************************
58  * Function:    get_file_list
59  *
60  * Description: For the given valid directory  path, returns the list
61  *              all directories or files in that path.
62  *
63  * Input:   'dirname' the directory path.
64  *          'file_type' if this takes the value DIR_TYPE then
65  *              returns the list of directories in that path.
66  *          If its of type FILE_TYPE then returns the list of files
67  *          in that path.
68  *          'count' pointer to number of elements returned in the
69  *          return string. 
70  *
71  * Output:  List of  directories/files in that path.
72  *
73  *********************************************************************/
74
75 char *get_file_list(const char *dirname, int file_type, uint32_t *count)
76 {
77
78     DIR           *pdir = NULL;
79     struct dirent *pdirent = NULL;
80     int           curr_offset = 0;
81     int           byte_count = 0;
82     int           file_count = 0;
83     char          *ret_str = NULL;
84     char          filename[MAX_PATH_SIZE];
85     int           cond1, cond2;
86
87     if ((dirname == NULL) || ((pdir = opendir(dirname)) == NULL )) {
88         if (dirname == NULL) {
89             report("%s %s:line %d %s", __FILE__, __FUNCTION__, __LINE__,
90                    "NULL directory is passed as parameter to funtion");
91         } else {
92             report("%s %s:line %d Error in opening the dir %s", __FILE__,
93                    __FUNCTION__, __LINE__, dirname);
94         }
95         if (count)
96             *count = 0;
97         return NULL;
98     }
99
100     while (1) {
101         if ((pdirent = readdir(pdir)) == NULL)
102             break;
103
104         /* Skip over '.' and '..' directores */
105         if ((pdirent->d_name[0] == '.') ||
106             !strcmp(pdirent->d_name, FILENAME_NUM_REF))
107             continue;
108         
109         sprintf(filename, "%s/%s", dirname, pdirent->d_name);
110         cond1 = (file_type == FILE_TYPE) && is_directory(filename);
111         cond2 = (file_type == DIR_TYPE) && (!is_directory(filename));
112
113         if (cond1 || cond2)
114             continue;
115
116         /* Calculate the number of bytes for this new entry.*/                    
117         byte_count += strlen(pdirent->d_name) + 1;
118         file_count++;
119     }
120     if (count)
121         *count = file_count;
122     
123     if (file_count != 0) {
124         
125         /* need one extra one for the finall NULL terminator*/
126         if ((ret_str = (char *) malloc(byte_count + 1)) == NULL) {
127             report("get_file_list() failed to malloc(%d)",byte_count+1);
128             closedir(pdir);
129             return NULL;
130         }    
131         
132         rewinddir(pdir);
133         
134         while (file_count != 0) {
135             if ((pdirent = readdir(pdir)) == NULL)
136                 break;
137
138             if ((pdirent->d_name[0] == '.') ||
139                 !strcmp(pdirent->d_name, FILENAME_NUM_REF))
140                 continue;
141             
142             sprintf(filename, "%s/%s", dirname, pdirent->d_name);
143             cond1 = (file_type == FILE_TYPE) && is_directory(filename);
144             cond2 = (file_type == DIR_TYPE) && (!is_directory(filename));
145
146             if (cond1 || cond2)
147                 continue;
148
149             strcpy(ret_str + curr_offset, pdirent->d_name);
150             curr_offset = curr_offset + strlen(pdirent->d_name) + 1;
151             file_count--;
152         }
153         /* Put in the finall null terminator*/
154         ret_str[byte_count] = '\0';
155     }
156     closedir(pdir);
157     return ret_str;
158 }
159
160
161 /*********************************************************************
162  * Function:    is_directory
163  *
164  * Description: Checks if given filename is a directory or not.
165  *              all directories or files in that path.
166  *
167  * Input:   'filename' the directory path to be checked.
168  *
169  * Output:  Returns 1 if its a directory else 0.
170  *
171  *********************************************************************/
172
173 int is_directory(const char *filename)
174 {
175
176     struct stat statf;
177     int result;
178
179     result = stat(filename, &statf);
180     return ((result == SUCCESS) && (statf.st_mode & S_IFDIR));
181 }
182
183 /*********************************************************************
184  * Function:    read_string
185  *
186  * Description: For the given valid file path, reads the data in
187  *              that file.
188  *
189  * Input:   'filepath' the file whose data is to be accessed.
190  *          'lustre_var' the data from the file is read into
191  *           this variable, returned to the requestor.
192  *          'var_max_size' the max size of the string
193  *          'report_error' boolean if error should be reported on 
194  *           missing filepath
195  *
196  * Output:  Returns SUCCESS if read successfully from file else
197  *          returns ERROR.
198  *********************************************************************/
199  
200 int  read_string(const char *filepath, char *lustre_var, size_t var_max_size)
201 {
202     FILE    *fptr = NULL;
203     int     len = 0;
204     int     ret_val = SUCCESS;
205     int     report_error = 1;
206
207     if ((filepath == NULL) || (lustre_var == NULL)) {
208         report("%s %s:line %d %s", __FILE__, __FUNCTION__, __LINE__,
209                "Input parameter is NULL");
210         ret_val = ERROR;
211     } else {
212         fptr = fopen(filepath, "r");
213
214         if (fptr == NULL) {
215             if(report_error)
216                 report("%s %s:line %d Unable to open the file %s", __FILE__,
217                        __FUNCTION__, __LINE__, filepath);
218             ret_val = ERROR;
219         } else {
220             if (fgets(lustre_var, var_max_size, fptr) == NULL) {
221                 report("%s %s:line %d read failed for file %s", __FILE__,
222                        __FUNCTION__, __LINE__, filepath);
223                  ret_val = ERROR;
224             } else {
225                 len = strlen(lustre_var);
226                 /*
227                     Last char is EOF, before string ends,
228                     so '\0' is moved to last but one.
229                 */
230                 lustre_var[len-1] = lustre_var[len];
231             }
232             fclose(fptr);
233         }
234     }
235     return ret_val;
236 }
237
238 /**************************************************************************
239  * Function:   lustrefs_ctrl
240  *
241  * Description: Execute /etc/init.d/lustre script for starting,
242  *              stopping and restarting Lustre services in child process.
243  *
244  * Input:  Start/Stop/Restart Command Number.
245  * Output: Returns  void
246  *
247  **************************************************************************/
248
249 void lustrefs_ctrl(int command)
250 {
251     char *cmd[3];
252
253     cmd[0] = LUSTRE_SERVICE;
254     switch (command) {
255     case ONLINE:
256         cmd[1] = "start";
257         break;
258     case OFFLINE:
259         cmd[1] = "stop";
260         break;
261     case RESTART:
262         cmd[1] = "restart";
263         break;
264     default:
265         return;
266     }
267
268     cmd[2] = (char *)0;
269
270     if (fork() == 0) {
271         execvp(cmd[0], cmd);
272         report("failed to execvp(\'%s %s\')",cmd[0],cmd[1]);
273     }
274 }
275
276 /*****************************************************************************
277  * Function:     get_sysstatus
278  *
279  * Description:  Read /var/lustre/sysStatus file, and based on file contents
280  *               return the status of Lustre services.
281  *
282  * Input:   void
283  * Output:  Return ONLINE/OFFLINE/ONLINE PENDING/OFFLINE PENDING status
284  *          values.
285  *
286  ****************************************************************************/
287
288 int get_sysstatus(void)
289 {
290     int     ret_val = ERROR ;
291     char    sys_status[50] = {0};
292     
293     if(SUCCESS == read_string(FILENAME_SYS_STATUS,sys_status,sizeof(sys_status)))
294     {
295         if (memcmp(sys_status, STR_ONLINE_PENDING,strlen(STR_ONLINE_PENDING)) == 0)
296             ret_val = ONLINE_PENDING;
297         else if (memcmp(sys_status, STR_ONLINE, strlen(STR_ONLINE)) == 0)
298             ret_val = ONLINE;
299         else if (memcmp(sys_status, STR_OFFLINE_PENDING,strlen(STR_OFFLINE_PENDING)) == 0)
300             ret_val = OFFLINE_PENDING;
301         else if (memcmp(sys_status, STR_OFFLINE, strlen(STR_OFFLINE)) == 0)
302             ret_val = OFFLINE;
303         else
304             report("%s %s:line %d Bad Contents in file %s \'%s\'", __FILE__,
305                 __FUNCTION__, __LINE__, FILENAME_SYS_STATUS,sys_status);
306     }
307     return ret_val;
308 }
309
310
311 /*****************************************************************************
312  * Function:     read_ulong
313  *
314  * Description:  Read long values from lproc and copy to the location
315  *               pointed by input parameter.
316  *
317  * Input:   file path, and pointer for data to be copied
318  *
319  * Output:  Return ERROR or SUCCESS.
320  *
321  ****************************************************************************/
322
323 int read_ulong(const char *file_path, unsigned long *valuep)
324 {
325     char    file_data[MAX_LINE_SIZE];
326     int     ret_val;
327
328     if ((ret_val = read_string(file_path, file_data,sizeof(file_data))) == SUCCESS){
329         *valuep = strtoul(file_data,NULL,10);
330     }
331     return ret_val;
332 }
333
334 /*****************************************************************************
335  * Function:     read_counter64
336  *
337  * Description:  Read counter64 values from lproc and copy to the location
338  *               pointed by input parameter.
339  *
340  * Input:   file path, and pointer for data to be copied
341  *
342  * Output:  Return ERROR or SUCCESS.
343  *
344  ****************************************************************************/
345
346 int read_counter64(const char *file_path, counter64 *c64,int factor)
347 {
348     char    file_data[MAX_LINE_SIZE];
349     int     ret_val;
350     unsigned long long tmp = 0;
351
352     if ((ret_val = read_string(file_path, file_data,sizeof(file_data))) == SUCCESS) {
353         tmp = atoll(file_data) * factor;
354         c64->low = (unsigned long) (0x0FFFFFFFF & tmp);
355         tmp >>= 32; /* Shift right by 4 bytes */
356         c64->high = (unsigned long) (0x0FFFFFFFF & tmp);
357     }
358     return ret_val;
359 }
360
361 /*****************************************************************************
362  * Function:     get_nth_entry_from_list
363  *
364  * Description:  Find the n'th entry from a null terminated list of string
365  *
366  * Input:   dir_list - the list
367  *          num - the number of elements in the list
368  *          index - the index we are looking for
369  *
370  * Output:  Return NULL on failure, or the string name on success.
371  *
372  ****************************************************************************/
373
374 const char *get_nth_entry_from_list(const char* dir_list,int num,int index)
375 {
376     int i;
377     int cur_ptr = 0;
378     for(i=0;i<num;i++){
379         
380         /* 
381          * if we've reached the end of the list for some reason
382          * because num was wrong then stop processing
383          */
384         if( *(dir_list+cur_ptr) == 0)
385             break;
386             
387         /* If we've found the right one */    
388         if( i == index )
389             return dir_list+cur_ptr;
390             
391         /* Move to the next one*/            
392         cur_ptr += strlen(dir_list + cur_ptr)+1;
393     }
394     return NULL;
395 }
396
397 /*****************************************************************************
398  * Function:    report
399  *
400  * Description: This function used to report error msg to stderr and log into
401  *    log file(default file:/var/log/snmpd.log) when agent is started with
402  *    debug option -Dlsnmpd
403  * Input:   format string and variable arguments.
404  * Output:  void
405  ****************************************************************************/
406
407 void report(const char *fmt, ...)
408 {
409     char buf[1024];
410
411     va_list arg_list;
412     va_start(arg_list, fmt);
413     vsprintf(buf, fmt, arg_list);
414     va_end(arg_list);
415
416     DEBUGMSGTL(("lsnmpd", "%s\n", buf));
417     fprintf(stderr, "%s\n", buf);
418 }
419
420
421
422 /**************************************************************************
423  * Function:   oid_table_ulong_handler
424  *
425  * Description: Fetch a unsigned long from the given location.
426  *              Setup var_len, and return a pointer to the data.
427  *
428  * Input:  file_path, and var_len pointer
429  *
430  * Output: NULL on failure, or pointer to data
431  *
432  **************************************************************************/
433
434 unsigned char* 
435     oid_table_ulong_handler(
436         const char* file_path,
437         size_t  *var_len)
438 {
439     static unsigned long ulong_ret;
440     if (SUCCESS != read_ulong(file_path,&ulong_ret))
441         return NULL;
442     *var_len = sizeof(ulong_ret);
443     return  (unsigned char *) &ulong_ret;
444 }
445
446 /**************************************************************************
447  * Function:   oid_table_c64_handler
448  *
449  * Description: Fetch a counter64 from the given location.
450  *              Setup var_len, and return a pointer to the data.
451  *
452  * Input:  file_path, and var_len pointer
453  *
454  * Output: NULL on failure, or pointer to data
455  *
456  **************************************************************************/
457
458 unsigned char* oid_table_c64_handler(const char* file_path,size_t  *var_len)
459 {
460     static counter64 c64;
461     if (SUCCESS != read_counter64(file_path,&c64,1))
462         return NULL;
463     *var_len = sizeof(c64);
464     return (unsigned char *) &c64;
465 }
466
467 /**************************************************************************
468  * Function:   oid_table_c64_kb_handler
469  *
470  * Description: Fetch a counter64 from the given location.
471  *              Setup var_len, and return a pointer to the data.
472  *              Different than oid_table_c64_handler in that
473  *              the original value is multiplied by 1024 before converting
474  *              to a counter64.  (e.g. turn KB into a Byte scaled value)
475  *
476  * Input:  file_path, and var_len pointer
477  *
478  * Output: NULL on failure, or pointer to data
479  *
480  **************************************************************************/
481
482 unsigned char* oid_table_c64_kb_handler(const char* file_path,size_t  *var_len)
483 {
484     static counter64 c64;
485     /* scale by factor of 1024*/
486     if (SUCCESS != read_counter64(file_path,&c64,1024))
487         return NULL;
488     *var_len = sizeof(c64);
489     return (unsigned char *) &c64;
490 }
491
492 /**************************************************************************
493  * Function:   oid_table_obj_name_handler
494  *
495  * Description: Just copy the file_path and return as the output value.
496  *
497  * Input:  file_path, and var_len pointer
498  *
499  * Output: NULL on failure, or pointer to data
500  *
501  **************************************************************************/
502
503 unsigned char* 
504     oid_table_obj_name_handler(
505         const char* file_path,
506         size_t  *var_len)
507 {
508     static unsigned char string[SPRINT_MAX_LEN];
509     *var_len = strlen(file_path);
510     *var_len = MIN_LEN(*var_len, sizeof(string));
511     memcpy(string, file_path, *var_len);
512     return (unsigned char *) string;
513 }
514
515 /**************************************************************************
516  * Function:   oid_table_string_handler
517  *
518  * Description: Fetch a string from the given location.
519  *              Setup var_len, and return a pointer to the data.
520  *
521  * Input:  file_path, and var_len pointer
522  *
523  * Output: NULL on failure, or pointer to data
524  *
525  **************************************************************************/
526
527 unsigned char* 
528     oid_table_string_handler(
529         const char* file_path,
530         size_t  *var_len)
531 {
532     static unsigned char string[SPRINT_MAX_LEN];
533     if( SUCCESS != read_string(file_path, (char *)string,sizeof(string)))
534         return NULL;
535     *var_len = strlen((char *)string);
536     return (unsigned char *) string;
537 }
538
539
540 /**************************************************************************
541  * Function:   oid_table_is_directory_handler
542  *
543  * Description: Determine if the file_path is a directory.  
544  *              Setup a boolean return value.
545  *              Setup var_len, and return a pointer to the data.
546  *
547  * Input:  file_path, and var_len pointer
548  *
549  * Output: NULL on failure, or pointer to data
550  *
551  **************************************************************************/
552
553 unsigned char* 
554     oid_table_is_directory_handler(
555         const char* file_path,
556         size_t *var_len)
557 {
558     static long long_ret;
559     long_ret =  is_directory(file_path);
560     *var_len = sizeof(long_ret);
561     return (unsigned char *) &long_ret;
562 }
563
564 /**************************************************************************
565  * Function:   var_genericTable
566  *
567  * Description: Handle Table driven OID processing
568  *
569  **************************************************************************/
570
571 unsigned char *
572 var_genericTable(struct variable *vp,
573             oid     *name,
574             size_t  *length,
575             int     exact,
576             size_t  *var_len,
577             WriteMethod **write_method,
578             const char *path,
579             struct oid_table *ptable)
580 {
581     char *dir_list;
582     uint32_t num;
583     int  deviceindex;
584     unsigned char *ret_val = NULL;
585     int i=0;
586     const char* obj_name;
587     
588     
589     /*
590      * Get the list of file.  If there are no elements
591      * return nothing
592      */
593     if( 0 == (dir_list = get_file_list(path, DIR_TYPE, &num)))
594         return NULL;
595
596     /*
597      * Setup the table
598      */
599     if (header_simple_table(vp,name,length,exact,var_len,write_method, num)
600                                                 == MATCH_FAILED )
601         goto cleanup_and_exit;
602
603     /*
604      * The number of the device we're looking at
605      */
606     deviceindex = name[*length - 1] - 1;
607
608     /*
609      * If we couldn't find this element
610      * something must have recently changed return
611      * nothing
612      */
613     if(deviceindex >= num){
614         report("deviceindex=%d exceeds number of elements=%d",deviceindex,num);
615         goto cleanup_and_exit;
616     }
617
618     /*
619      * Fetch the object name from the list
620      */
621     obj_name = get_nth_entry_from_list(dir_list,num,deviceindex);
622     if(obj_name == NULL){
623         /*
624          * Note this should never really happen because we check deviceindex >=num
625          * above.  And dir_list should be consitent with num
626          * but just in case...
627          */
628         report("object name not found in list",deviceindex,num);
629         goto cleanup_and_exit;
630     }
631
632     /*
633      * Find the matching magic - or the end of the list
634      */
635     while(ptable[i].magic != vp->magic && ptable[i].magic != 0)
636         i++;
637
638     /*
639      * If we didn't find a matching entry return
640      */
641     if(ptable[i].magic==0)
642         goto cleanup_and_exit;
643
644     /*
645      * If the name is NULL is a special case and 
646      * just just pass the obj_name as the file_path
647      * otherwise we create a file path from the given components
648      */
649     if(ptable[i].name != 0){
650         char file_path[MAX_PATH_SIZE];
651         sprintf(file_path, "%s%s/%s",path,obj_name,ptable[i].name);
652         ret_val =  ptable[i].fhandler(file_path,var_len);
653     }
654     else
655         ret_val =  ptable[i].fhandler(obj_name,var_len);
656
657 cleanup_and_exit:
658     free(dir_list);
659     return ret_val;
660 };
661
662 /**************************************************************************
663  * Function:   stats_values
664  *
665  * Description: Setup nb_sample, min, max, sum and sum_square stats values
666                 for name_value from filepath.
667  *
668  * Input:  filepath, name_value,
669  *         pointer to nb_sample, min, max, sum, sum_square
670  *
671  * Output: SUCCESS or ERROR on failure
672  *
673  **************************************************************************/
674 int stats_values(char * filepath,char * name_value, unsigned long long * nb_sample, unsigned long long * min, unsigned long long * max, unsigned long long * sum, unsigned long long * sum_square)
675 {
676   FILE * statfile;
677   char line[MAX_LINE_SIZE];
678   int nbReadValues = 0;
679
680   if( (statfile=fopen(filepath,"r")) == NULL) {
681     report("stats_value() failed to open %s",filepath);
682     return ERROR;
683   }
684 /*find the good line for name_value*/
685   do {
686     if( fgets(line,MAX_LINE_SIZE,statfile) == NULL ) {
687       report("stats_values() failed to find %s values in %s stat_file",name_value,statfile);
688       goto error_out;
689     }
690   } while ( strstr(line,name_value) == NULL );
691 /*get stats*/
692   if((nbReadValues=sscanf(line,"%*s %llu %*s %*s %llu %llu %llu %llu",nb_sample,min,max,sum,sum_square)) == 5) {
693     goto success_out;
694   } else if( nbReadValues == 1 && *nb_sample == 0) {
695     *min = *max = *sum = *sum_square = 0;
696     goto success_out;
697   } else {
698     report("stats_values() failed to read stats_values for %s value in %s stat_file",name_value,statfile);
699     goto error_out;
700   }
701
702 success_out :
703   fclose(statfile);
704   return SUCCESS;
705 error_out :
706   fclose(statfile);
707   return ERROR;
708 }
709
710 /**************************************************************************
711  * Function:   mds_stats_values
712  *
713  * Description: Setup nb_sample, min, max, sum and sum_square stats values
714                 for mds stats name_value .
715  *
716  * Input:  name_value,
717  *         pointer to nb_sample, min, max, sum, sum_square
718  *
719  * Output: SUCCESS or ERROR on failure
720  *
721  **************************************************************************/
722 extern int mds_stats_values(char * name_value, unsigned long long * nb_sample, unsigned long long * min, unsigned long long * max, unsigned long long * sum, unsigned long long * sum_square)
723 {
724   unsigned long long tmp_nb_sample=0,tmp_min=0,tmp_max=0,tmp_sum=0,tmp_sum_square=0;
725   glob_t path;
726
727 /*we parse the three MDS stat files and sum values*/
728   if (cfs_get_param_paths(&path, "mdt/MDS/mds/stats") != 0)
729     return ERROR;
730   if( stats_values(path.gl_pathv[0],name_value,&tmp_nb_sample,&tmp_min,&tmp_max,&tmp_sum,&tmp_sum_square) == ERROR ) {
731     cfs_free_param_data(&path);
732     return ERROR;
733   } else {
734     *nb_sample=tmp_nb_sample;
735     *min=tmp_min;
736     *max=tmp_max;
737     *sum=tmp_sum;
738     *sum_square=tmp_sum_square;
739   }
740   cfs_free_param_data(&path);
741
742   if (cfs_get_param_paths(&path, "mdt/MDS/mds_readpage/stats") != 0)
743     return ERROR;
744   if( stats_values(path.gl_pathv[0],name_value,&tmp_nb_sample,&tmp_min,&tmp_max,&tmp_sum,&tmp_sum_square) == ERROR ) {
745     cfs_free_param_data(&path);
746     return ERROR;
747   } else {
748     *nb_sample += tmp_nb_sample;
749     *min += tmp_min;
750     *max += tmp_max;
751     *sum += tmp_sum;
752     *sum_square += tmp_sum_square;
753   }
754   cfs_free_param_data(&path);
755
756   if (cfs_get_param_paths(&path, "mdt/MDS/mds_setattr/stats") != 0)
757     return ERROR;
758   if( stats_values(path.gl_pathv[0],name_value,&tmp_nb_sample,&tmp_min,&tmp_max,&tmp_sum,&tmp_sum_square) == ERROR ) {
759     cfs_free_param_data(&path);
760     return ERROR;
761   } else {
762     *nb_sample += tmp_nb_sample;
763     *min += tmp_min;
764     *max += tmp_max;
765     *sum += tmp_sum;
766     *sum_square += tmp_sum_square;
767   }
768   cfs_free_param_data(&path);
769   
770   return SUCCESS;
771 }
772
773 void convert_ull(counter64 *c64, unsigned long long ull, size_t *var_len)
774 {
775         *var_len  = sizeof(*c64);
776         c64->low  = (unsigned long long) (0x0ffffffff & ull);
777         ull >>= 32;
778         c64->high = (unsigned long long) (0x0ffffffff & ull);
779 }
780