From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm <linux-nvdimm@lists.01.org>
Subject: Re: [PATCH v5] ndctl: Add support for get bus and region persistence domain
Date: Wed, 21 Mar 2018 11:39:38 -0600 [thread overview]
Message-ID: <20180321173938.GB16113@linux.intel.com> (raw)
In-Reply-To: <CAPcyv4h+dSMP4hHxx+VspD5aJE3HzhSGt-gGpUQMS3P6wJiP6Q@mail.gmail.com>
On Tue, Mar 20, 2018 at 08:41:25PM -0700, Dan Williams wrote:
> On Tue, Mar 20, 2018 at 3:50 PM, Dave Jiang <dave.jiang@intel.com> wrote:
<>
> > +static int region_persistence_scan(struct ndctl_region *region)
> > +{
> > + struct ndctl_ctx *ctx = ndctl_region_get_ctx(region);
> > + char *pd_path;
> > + FILE *pf;
> > + char buf[64];
> > + int rc = 0;
> > + enum ndctl_persistence_domain pd = PERSISTENCE_NONE;
> > +
> > + region->persistence_domain = PERSISTENCE_NONE;
> > + if (asprintf(&pd_path, "%s/persistence_domain",
> > + region->region_path) < 0) {
> > + rc = -errno;
> > + err(ctx, "region persist domain path allocation failure\n");
> > + return rc;
> > + }
> > +
> > + pf = fopen(pd_path, "re");
> > + if (!pf) {
> > + rc = -errno;
> > + free(pd_path);
> > + return rc;
> > + }
> > +
> > + do {
> > + rc = fscanf(pf, "%s", buf);
> > + if (rc == EOF) {
> > + if (ferror(pf)) {
> > + rc = -errno;
> > + goto out;
> > + }
> > + } else if (rc == 1)
> > + pd = region_get_pd_type(buf);
> > +
> > + if (region->persistence_domain < pd)
> > + region->persistence_domain = pd;
> > + } while (rc != EOF);
>
> I would expect sysfs_read_attr() here? I don't otherwise see a reason
> to have special case code for this attribute.
And when using sysfs_read_attr() we need to be sure to have a buffer size of
SYSFS_ATTR_SIZE instead of a hard coded 64.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
prev parent reply other threads:[~2018-03-21 17:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-20 22:50 [PATCH v5] ndctl: Add support for get bus and region persistence domain Dave Jiang
2018-03-21 3:41 ` Dan Williams
2018-03-21 17:39 ` Ross Zwisler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180321173938.GB16113@linux.intel.com \
--to=ross.zwisler@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=linux-nvdimm@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.