[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 2/4] nvdimm: warn if the backend is not a DAX
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v2 2/4] nvdimm: warn if the backend is not a DAX device |
Date: |
Wed, 7 Jun 2017 16:14:45 +0100 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Tue, Jun 06, 2017 at 03:22:27PM +0800, Haozhong Zhang wrote:
> diff --git a/util/osdep.c b/util/osdep.c
> index a2863c8e53..02881f96bc 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -471,3 +471,64 @@ writev(int fd, const struct iovec *iov, int iov_cnt)
> return readv_writev(fd, iov, iov_cnt, true);
> }
> #endif
> +
> +#ifdef __linux__
> +static ssize_t qemu_dev_dax_sysfs_read(int fd, const char *entry,
> + char *buf, size_t len)
> +{
> + ssize_t read_bytes;
> + struct stat st;
> + unsigned int major, minor;
> + char *path, *pos;
> + int sysfs_fd;
> +
> + if (fstat(fd, &st)) {
> + return 0;
> + }
> +
> + major = major(st.st_rdev);
> + minor = minor(st.st_rdev);
> + path = g_strdup_printf("/sys/dev/char/%u:%u/%s", major, minor, entry);
> +
> + sysfs_fd = open(path, O_RDONLY);
> + g_free(path);
> + if (sysfs_fd == -1) {
> + return 0;
> + }
> +
> + read_bytes = read(sysfs_fd, buf, len - 1);
> + close(sysfs_fd);
> + if (read_bytes > 0) {
> + buf[read_bytes] = '\0';
> + pos = g_strstr_len(buf, read_bytes, "\n");
> + if (pos) {
> + *pos = '\0';
> + }
Should read_bytes be adjusted since we made the string shorter?
signature.asc
Description: PGP signature
- Re: [Qemu-devel] [PATCH v2 3/4] nvdimm: add a boolean option "restrict", (continued)
Re: [Qemu-devel] [PATCH v2 3/4] nvdimm: add a boolean option "restrict", Michael S. Tsirkin, 2017/06/08
[Qemu-devel] [PATCH v2 1/4] nvdimm: add a macro for property "label-size", Haozhong Zhang, 2017/06/06
[Qemu-devel] [PATCH v2 2/4] nvdimm: warn if the backend is not a DAX device, Haozhong Zhang, 2017/06/06