]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Merge tag 'vfs-6.13.tmpfs' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 18 Nov 2024 19:05:26 +0000 (11:05 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 18 Nov 2024 19:05:26 +0000 (11:05 -0800)
Pull tmpfs case folding updates from Christian Brauner:
 "This adds case-insensitive support for tmpfs.

  The work contained in here adds support for case-insensitive file
  names lookups in tmpfs. The main difference from other casefold
  filesystems is that tmpfs has no information on disk, just on RAM, so
  we can't use mkfs to create a case-insensitive tmpfs. For this
  implementation, there's a mount option for casefolding. The rest of
  the patchset follows a similar approach as ext4 and f2fs.

  The use case for this feature is similar to the use case for ext4, to
  better support compatibility layers (like Wine), particularly in
  combination with sandboxing/container tools (like Flatpak).

  Those containerization tools can share a subset of the host filesystem
  with an application. In the container, the root directory and any
  parent directories required for a shared directory are on tmpfs, with
  the shared directories bind-mounted into the container's view of the
  filesystem.

  If the host filesystem is using case-insensitive directories, then the
  application can do lookups inside those directories in a
  case-insensitive way, without this needing to be implemented in
  user-space. However, if the host is only sharing a subset of a
  case-insensitive directory with the application, then the parent
  directories of the mount point will be part of the container's root
  tmpfs. When the application tries to do case-insensitive lookups of
  those parent directories on a case-sensitive tmpfs, the lookup will
  fail"

* tag 'vfs-6.13.tmpfs' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
  tmpfs: Initialize sysfs during tmpfs init
  tmpfs: Fix type for sysfs' casefold attribute
  libfs: Fix kernel-doc warning in generic_ci_validate_strict_name
  docs: tmpfs: Add casefold options
  tmpfs: Expose filesystem features via sysfs
  tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs
  tmpfs: Add casefold lookup support
  libfs: Export generic_ci_ dentry functions
  unicode: Recreate utf8_parse_version()
  unicode: Export latest available UTF-8 version number
  ext4: Use generic_ci_validate_strict_name helper
  libfs: Create the helper function generic_ci_validate_strict_name()

1  2 
include/linux/fs.h
mm/shmem.c

index 3e53ba079f17f7cff6e34bd166e2d039742cf291,001d580af862f2e76131c9d700c89d5e3977b1ef..eae7ce884030759c40b57571e1a38b69237d7740
@@@ -45,7 -45,7 +45,8 @@@
  #include <linux/slab.h>
  #include <linux/maple_tree.h>
  #include <linux/rw_hint.h>
 +#include <linux/file_ref.h>
+ #include <linux/unicode.h>
  
  #include <asm/byteorder.h>
  #include <uapi/linux/fs.h>
diff --cc mm/shmem.c
index 87c9e38c07631f51090e7eb42689620f4ec77971,1389a29a18bf8a8ef023336e62eb61d12b10fa07..c7881e16f4bee94e7bae19922fc3f69e600641d7
@@@ -4943,9 -5123,69 +5120,69 @@@ static struct file_system_type shmem_fs
        .parameters     = shmem_fs_parameters,
  #endif
        .kill_sb        = kill_litter_super,
 -      .fs_flags       = FS_USERNS_MOUNT | FS_ALLOW_IDMAP,
 +      .fs_flags       = FS_USERNS_MOUNT | FS_ALLOW_IDMAP | FS_MGTIME,
  };
  
+ #if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS)
+ #define __INIT_KOBJ_ATTR(_name, _mode, _show, _store)                 \
+ {                                                                     \
+       .attr   = { .name = __stringify(_name), .mode = _mode },        \
+       .show   = _show,                                                \
+       .store  = _store,                                               \
+ }
+ #define TMPFS_ATTR_W(_name, _store)                           \
+       static struct kobj_attribute tmpfs_attr_##_name =       \
+                       __INIT_KOBJ_ATTR(_name, 0200, NULL, _store)
+ #define TMPFS_ATTR_RW(_name, _show, _store)                   \
+       static struct kobj_attribute tmpfs_attr_##_name =       \
+                       __INIT_KOBJ_ATTR(_name, 0644, _show, _store)
+ #define TMPFS_ATTR_RO(_name, _show)                           \
+       static struct kobj_attribute tmpfs_attr_##_name =       \
+                       __INIT_KOBJ_ATTR(_name, 0444, _show, NULL)
+ #if IS_ENABLED(CONFIG_UNICODE)
+ static ssize_t casefold_show(struct kobject *kobj, struct kobj_attribute *a,
+                       char *buf)
+ {
+               return sysfs_emit(buf, "supported\n");
+ }
+ TMPFS_ATTR_RO(casefold, casefold_show);
+ #endif
+ static struct attribute *tmpfs_attributes[] = {
+ #if IS_ENABLED(CONFIG_UNICODE)
+       &tmpfs_attr_casefold.attr,
+ #endif
+       NULL
+ };
+ static const struct attribute_group tmpfs_attribute_group = {
+       .attrs = tmpfs_attributes,
+       .name = "features"
+ };
+ static struct kobject *tmpfs_kobj;
+ static int __init tmpfs_sysfs_init(void)
+ {
+       int ret;
+       tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj);
+       if (!tmpfs_kobj)
+               return -ENOMEM;
+       ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group);
+       if (ret)
+               kobject_put(tmpfs_kobj);
+       return ret;
+ }
+ #endif /* CONFIG_SYSFS && CONFIG_TMPFS */
  void __init shmem_init(void)
  {
        int error;