Sha256: df5ee3787af00d31db9e1d1ebb2ba592316b63984914910d8ad207710a52a016

Contents?: true

Size: 539 Bytes

Versions: 7

Compression:

Stored size: 539 Bytes

Contents

static VALUE getDiskStats (volatile VALUE obj, volatile VALUE path) {
	FILE *file = fopen("/proc/diskstats", "r") ;
	if(!file) return rb_ary_new() ;

	char lines[120] ;
	unsigned long long read, write ;
	char *p = StringValuePtr(path) ;

	while(fgets(lines, 119, file)) {
		sscanf(lines, "%*s %*s %s %*s %*s %llu %*s %*s %*s %llu", lines, &read, &write) ;

		if(strcmp(lines, p) == 0) {
			fclose(file) ;

			return rb_ary_new_from_args(
				2,
				ULL2NUM(read),
				ULL2NUM(write)
			) ;
		}
	}

	fclose(file) ;
	return rb_ary_new() ;
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
linux_stat-2.6.0 ext/fs_stat/disk_stat.h
linux_stat-2.5.3 ext/fs_stat/disk_stat.h
linux_stat-2.5.2 ext/fs_stat/disk_stat.h
linux_stat-2.5.1 ext/fs_stat/disk_stat.h
linux_stat-2.5.0 ext/fs_stat/disk_stat.h
linux_stat-2.4.0 ext/fs_stat/disk_stat.h
linux_stat-2.3.0 ext/fs_stat/disk_stat.h