+ int f;
+ struct stat st;
+ uint64_t size;
+
+ log_fct("Analyze %s", dname);
+
+ f = open(dname, O_RDONLY|O_NOCTTY|O_NONBLOCK|O_CLOEXEC);
+
+ if (f < 0) {
+ log_fct("Could not open file %s: %s", dname, strerror(errno));
+ goto fail;
+ }
+
+ if (fstat(f, &st) < 0) {
+ log_fct("fstat fails %s: %s", dname, strerror(errno));
+ goto fail;
+ }
+
+ if (!S_ISBLK(st.st_mode)) {
+ log_fct("!S_ISBLK fails %s", dname);
+ goto fail;
+ }
+
+ size = (uint64_t)-1;
+ /* So, it's a block device. Let's make sure the ioctls work */
+ if (ioctl(f, BLKGETSIZE64, &size) < 0) {
+ log_fct("ioctl fails %s: %s", dname, strerror(errno));
+ goto fail;
+ }
+
+ if (size <= 0 || size == (uint64_t) -1) {
+ log_fct("ioctl wrong size %s: %ld", dname, size);
+ goto fail;
+ }
+
+ fail:
+ close(f);
+}
+
+void
+atasmart_psensor_list_append(struct psensor ***sensors, int values_max_length)
+{
+ char **paths, **tmp, *id;