@@ -1019,6 +1019,30 @@ DAXCTL_EXPORT unsigned long long daxctl_dev_get_size(struct daxctl_dev *dev)
return dev->size;
}
+DAXCTL_EXPORT int daxctl_dev_set_size(struct daxctl_dev *dev, unsigned long long size)
+{
+ struct daxctl_ctx *ctx = daxctl_dev_get_ctx(dev);
+ char buf[SYSFS_ATTR_SIZE];
+ char *path = dev->dev_buf;
+ int len = dev->buf_len;
+
+ if (snprintf(path, len, "%s/size", dev->dev_path) >= len) {
+ err(ctx, "%s: buffer too small!\n",
+ daxctl_dev_get_devname(dev));
+ return -ENXIO;
+ }
+
+ sprintf(buf, "%#llx\n", size);
+ if (sysfs_write_attr(ctx, path, buf) < 0) {
+ err(ctx, "%s: failed to set size\n",
+ daxctl_dev_get_devname(dev));
+ return -ENXIO;
+ }
+
+ dev->size = size;
+ return 0;
+}
+
DAXCTL_EXPORT int daxctl_dev_get_target_node(struct daxctl_dev *dev)
{
return dev->target_node;
@@ -75,3 +75,8 @@ global:
daxctl_memory_is_movable;
daxctl_memory_online_no_movable;
} LIBDAXCTL_6;
+
+LIBDAXCTL_8 {
+global:
+ daxctl_dev_set_size;
+} LIBDAXCTL_7;
@@ -68,6 +68,7 @@ int daxctl_dev_get_major(struct daxctl_dev *dev);
int daxctl_dev_get_minor(struct daxctl_dev *dev);
unsigned long long daxctl_dev_get_resource(struct daxctl_dev *dev);
unsigned long long daxctl_dev_get_size(struct daxctl_dev *dev);
+int daxctl_dev_set_size(struct daxctl_dev *dev, unsigned long long size);
struct daxctl_ctx *daxctl_dev_get_ctx(struct daxctl_dev *dev);
int daxctl_dev_is_enabled(struct daxctl_dev *dev);
int daxctl_dev_disable(struct daxctl_dev *dev);