static ssize_t nstype_show(struct device *dev, struct device_attribute *attr, char *buf) { struct nd_region *nd_region = to_nd_region(dev); return sprintf(buf, "%d\n", nd_region_to_nstype(nd_region)); }
static int is_uuid_busy(struct device *dev, void *data) { struct nd_region *nd_region = to_nd_region(dev->parent); u8 *uuid = data; switch (nd_region_to_nstype(nd_region)) { case ND_DEVICE_NAMESPACE_PMEM: { struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev); if (!nspm->uuid) break; if (memcmp(uuid, nspm->uuid, NSLABEL_UUID_LEN) == 0) return -EBUSY; break; } case ND_DEVICE_NAMESPACE_BLK: { struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); if (!nsblk->uuid) break; if (memcmp(uuid, nsblk->uuid, NSLABEL_UUID_LEN) == 0) return -EBUSY; break; } default: break; } return 0; }
static umode_t region_visible(struct kobject *kobj, struct attribute *a, int n) { struct device *dev = container_of(kobj, typeof(*dev), kobj); struct nd_region *nd_region = to_nd_region(dev); struct nd_interleave_set *nd_set = nd_region->nd_set; int type = nd_region_to_nstype(nd_region); if (a != &dev_attr_set_cookie.attr && a != &dev_attr_available_size.attr) return a->mode; if ((type == ND_DEVICE_NAMESPACE_PMEM || type == ND_DEVICE_NAMESPACE_BLK) && a == &dev_attr_available_size.attr) return a->mode; else if (is_nd_pmem(dev) && nd_set) return a->mode; return 0; }