Karel Zak wrote:
Peter, your opinion? Please.
Karel
- fd = open(filename, O_RDONLY|O_CREAT, 0666);
+#ifdef O_DIRECTORY
+ if ((fd = open(filename, O_RDONLY|O_DIRECTORY)) < 0)
+#endif
+ fd = open(filename, O_RDONLY|O_NOCTTY|O_CREAT, 0666);
This part is backwards. Instead of doing the unlikely case first, one
should simply:
fd = open(filename, O_RDONLY|O_NOCTTY|O_CREAT, 0666);
/* Linux doesn't like O_CREAT on a directory, even though it should be a
no-op */
if (fd < 0 && errno == EISDIR)
fd = open(filename, O_RDONLY|O_NOCTTY);
Note that the O_DIRECTORY is not necessary to the best of my knowledge.
-hpa
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html