#define EXTENDEDSD_NAME "extendedsd"
/* Minimum value of block id */
-#define BLOCK_ID_MIN 10
+#define BLOCK_ID_MIN 10
/* For 2.4 Backward Compatibility */
#define EXT_PRIMARY_SD_FIXID 1
/* Maximum number of thread */
-#define THREAD_MAX 5
+#define THREAD_MAX 5
-#define SPEEDCHECK 16
+#define SPEEDCHECK_SIZE 16
+#define SPEEDCHECK_CRITERION 4 /* MB/s */
#define PKGDIR_BUS_NAME "org.tizen.pkgdir_tool"
#define PKGDIR_PATH "/org/tizen/pkgdir_tool"
#define PKGDIR_INTERFACE "org.tizen.pkgdir_tool"
-#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
enum block_dev_operation {
BLOCK_DEV_MOUNT,
struct timespec start_time, end_time;
struct block_device *bdev;
struct block_data *data;
- char *buf;
+ char *buf = NULL;
int ret;
int result = 0;
int id;
}
_D("speed check: %s", data->devnode);
- fd = open(data->devnode, O_RDWR | O_SYNC);
- buf = calloc(1, SPEEDCHECK << 20);
- if (!buf) {
- _E("calloc() failed");
+ fd = open(data->devnode, O_RDONLY | O_DIRECT);
+ ret = posix_memalign((void**)&buf, 4096, SPEEDCHECK_SIZE << 20);
+ if (ret) {
+ _E("posix_memalign() failed");
result = -1;
- close(fd);
- goto out;
+ goto out_close;
}
+
clock_gettime(CLOCK_REALTIME, &start_time);
_I("start time: %lu.%lu", start_time.tv_sec, start_time.tv_nsec);
- ret = write(fd, buf, SPEEDCHECK << 20);
+ ret = read(fd, buf, SPEEDCHECK_SIZE << 20);
clock_gettime(CLOCK_REALTIME, &end_time);
_I("end time %lu.%lu", end_time.tv_sec, end_time.tv_nsec);
free(buf);
- time_diff = end_time.tv_sec - start_time.tv_sec;
- if (time_diff > 0 && (SPEEDCHECK / time_diff < 4)) {
+ if (ret < 0) {
+ _E("read() failed %d", errno);
result = -1;
- close(fd);
- goto out;
+ goto out_close;
}
- if (ret < 0) {
- _E("write() failed %d", errno);
+ time_diff = end_time.tv_sec - start_time.tv_sec;
+ if (time_diff > 0 && (SPEEDCHECK_SIZE / time_diff < SPEEDCHECK_CRITERION)) {
result = -1;
- close(fd);
- goto out;
+ goto out_close;
}
+out_close:
close(fd);
out:
return g_variant_new("(i)", result);