On Tue, Mar 20, 2018 at 08:41:25PM -0700, Dan Williams wrote: > On Tue, Mar 20, 2018 at 3:50 PM, Dave Jiang <[email protected]> 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 [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
