[Rpm-maint] [rpm-software-management/rpm] Auto-enable optimizations for non-rotational disks on Linux (#949)

Michael Schroeder notifications at github.com
Wed Feb 19 10:52:33 UTC 2020


mlschroe commented on this pull request.



> @@ -109,6 +121,27 @@ static char *getMntPoint(const char *dirName, dev_t dev)
     return res;
 }
 
+static int getRotational(const char *dirName, dev_t dev)
+{
+    int rotational = 1;	/* Be a good pessimist, assume the worst */
+#if defined(__linux__)
+    char *devpath = NULL;
+    FILE *f = NULL;
+
+    rasprintf(&devpath, "/sys/dev/block/%d:%d/queue/rotational",
+			major(dev), minor(dev));
+    if ((f = fopen(devpath, "r")) != NULL) {
+	int v;
+	if (fscanf(f, "%d", &v) == 1)
+	    rotational = v;

That maybe the case with current kernels, but with kernel version 6.0.0 it will probably return '-1' for some disks...

I'm just nitpicking because the rest of the code assumes that it returns a boolean, which is not something fscanf guarantees. Feel free to ignore this comment ;-)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/949#discussion_r381217245
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20200219/2d83d3a6/attachment-0001.html>


More information about the Rpm-maint mailing list