~ubuntu-branches/ubuntu/vivid/sysstat/vivid-proposed

« back to all changes in this revision

Viewing changes to common.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2011-02-07 20:57:05 UTC
  • mfrom: (12.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110207205705-6rbilpmalr1gkfra
Tags: 9.1.7-2
* Upload to unstable.
* debian/rules:
  + call dpkg-buildflags for initial values of CFLAGS & LDFLAGS;
  + use dh_auto_{configure,install,clean} debhelper commands;
  + provide build-arch and build-indep targets.
* Updated 00-Makefile.patch to make it possible to install isag only.
* 09-format-warning.patch: Fix a warning given by gcc -Wformat.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * sar, sadc, sadf, mpstat and iostat common routines.
3
 
 * (C) 1999-2009 by Sebastien GODARD (sysstat <at> orange.fr)
 
3
 * (C) 1999-2010 by Sebastien GODARD (sysstat <at> orange.fr)
4
4
 *
5
5
 ***************************************************************************
6
6
 * This program is free software; you can redistribute it and/or modify it *
264
264
 
265
265
/*
266
266
 ***************************************************************************
267
 
 * Find number of NFS-mounted points that are registered in
268
 
 * /proc/self/mountstats.
 
267
 * Read /proc/devices file and get device-mapper major number.
 
268
 * If device-mapper entry is not found in file, use DEFAULT_DEMAP_MAJOR
 
269
 * number.
269
270
 *
270
271
 * RETURNS:
271
 
 * Number of NFS-mounted points.
 
272
 * Device-mapper major number.
272
273
 ***************************************************************************
273
274
 */
274
 
int get_nfs_mount_nr(void)
 
275
unsigned int get_devmap_major(void)
275
276
{
276
277
        FILE *fp;
277
 
        char line[8192];
278
 
        char type_name[10];
279
 
        unsigned int nfs = 0;
280
 
 
281
 
        if ((fp = fopen(NFSMOUNTSTATS, "r")) == NULL)
282
 
                /* File non-existent */
283
 
                return 0;
284
 
 
285
 
        while (fgets(line, 8192, fp) != NULL) {
286
 
 
287
 
                if ((strstr(line, "mounted")) && (strstr(line, "on")) &&
288
 
                    (strstr(line, "with")) && (strstr(line, "fstype"))) {
289
 
        
290
 
                        sscanf(strstr(line, "fstype") + 6, "%10s", type_name);
291
 
                        if ((!strncmp(type_name, "nfs", 3)) && (strncmp(type_name, "nfsd", 4))) {
292
 
                                nfs ++;
293
 
                        }
 
278
        char line[128];
 
279
        unsigned int dm_major = DEFAULT_DEVMAP_MAJOR;
 
280
 
 
281
        if ((fp = fopen(DEVICES, "r")) == NULL)
 
282
                return dm_major;
 
283
 
 
284
        while (fgets(line, 128, fp) != NULL) {
 
285
 
 
286
                if (strstr(line, "device-mapper")) {
 
287
                        /* Read device-mapper major number */
 
288
                        sscanf(line, "%u", &dm_major);
294
289
                }
295
290
        }
296
291
 
297
292
        fclose(fp);
298
293
 
299
 
        return nfs;
 
294
        return dm_major;
300
295
}
301
296
 
302
297
/*
322
317
        char *e;
323
318
        int rc = 0;
324
319
 
325
 
        if (((e = getenv(ENV_TIME_FMT)) != NULL) && !strcmp(e, K_ISO)) {
 
320
        if (rectime == NULL) {
 
321
                strcpy(cur_date, "?/?/?");
 
322
        }
 
323
        else if (((e = getenv(ENV_TIME_FMT)) != NULL) && !strcmp(e, K_ISO)) {
326
324
                strftime(cur_date, sizeof(cur_date), "%Y-%m-%d", rectime);
327
325
                rc = 1;
328
326
        }
420
418
        while ((slash = strchr(name, '/'))) {
421
419
                *slash = '!';
422
420
        }
423
 
        snprintf(syspath, sizeof(syspath), "/sys/block/%s", name);
 
421
        snprintf(syspath, sizeof(syspath), "%s/%s", SYSFS_BLOCK, name);
424
422
        
425
423
        return !(access(syspath, F_OK));
426
424
}