| To: | Josef Bacik <jbacik@xxxxxxxxxxxx> |
|---|---|
| Subject: | Re: [PATCH] xfstests 311: test fsync with dm flakey |
| From: | Zach Brown <zab@xxxxxxxxxx> |
| Date: | Mon, 22 Apr 2013 15:31:14 -0700 |
| Cc: | linux-btrfs@xxxxxxxxxxxxxxx, xfs@xxxxxxxxxxx |
| Delivered-to: | xfs@xxxxxxxxxxx |
| In-reply-to: | <1366665213-17894-1-git-send-email-jbacik@xxxxxxxxxxxx> |
| References: | <1366665213-17894-1-git-send-email-jbacik@xxxxxxxxxxxx> |
| User-agent: | Mutt/1.5.21 (2010-09-15) |
> +static void drop_all_caches()
> +{
> + int value = 3;
> + int fd;
> +
> + if ((fd = open("/proc/sys/vm/drop_caches", O_WRONLY)) < 0) {
> + fprintf(stderr, "Error opening drop caches: %d\n", errno);
> + return;
> + }
> +
> + write(fd, &value, sizeof(int));
> + close(fd);
> +}
fwiw drop_caches takes an ascii string, not a native int:
open("/proc/sys/vm/drop_caches", O_WRONLY) = 3
write(3, "\3\0\0\0", 4) = -1 EINVAL (Invalid argument)
--- test.c.busted 2013-04-22 15:22:57.593575545 -0700
+++ test.c 2013-04-22 15:29:25.358072087 -0700
@@ -7,7 +7,7 @@
static void drop_all_caches()
{
- int value = 3;
+ char value[] = "3\n";
int fd;
if ((fd = open("/proc/sys/vm/drop_caches", O_WRONLY)) < 0) {
@@ -15,7 +15,7 @@
return;
}
- write(fd, &value, sizeof(int));
+ write(fd, value, sizeof(value) - 1);
close(fd);
}
open("/proc/sys/vm/drop_caches", O_WRONLY) = 3
write(3, "3\n", 2) = 2
and all this makes me think that the write() return should probably have
been checked :).
- z
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCH] xfstests 311: test fsync with dm flakey, Josef Bacik |
|---|---|
| Next by Date: | [PATCH 0/3] xfsprogs: manpage & usage string fixups, Eric Sandeen |
| Previous by Thread: | [PATCH] xfstests 311: test fsync with dm flakey, Josef Bacik |
| Next by Thread: | [PATCH 0/3] xfsprogs: manpage & usage string fixups, Eric Sandeen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |