X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=module%2Fzcommon%2Fzfs_namecheck.c;h=8508bc73442c40cba0d5c36280880c12f42eff5d;hb=refs%2Fheads%2Frertzinger%2Ffeature-zpool-get--p;hp=45730c6fc4bda0a8cf95392f31b38b665be820c1;hpb=9babb37438b58e77bad04e820d5702e15b79e6a6;p=zfs.git diff --git a/module/zcommon/zfs_namecheck.c b/module/zcommon/zfs_namecheck.c index 45730c6..8508bc7 100644 --- a/module/zcommon/zfs_namecheck.c +++ b/module/zcommon/zfs_namecheck.c @@ -59,7 +59,7 @@ valid_char(char c) * Snapshot names must be made up of alphanumeric characters plus the following * characters: * - * [-_.:] + * [-_.: ] */ int snapshot_namecheck(const char *path, namecheck_err_t *why, char *what) @@ -142,9 +142,22 @@ dataset_namecheck(const char *path, namecheck_err_t *why, char *what) * which is the same as MAXNAMELEN used in the kernel. * If ZFS_MAXNAMELEN value is changed, make sure to cleanup all * places using MAXNAMELEN. + * + * When HAVE_KOBJ_NAME_LEN is defined the maximum safe kobject name + * length is 20 bytes. This 20 bytes is broken down as follows to + * provide a maximum safe /[@snapshot] length of only + * 18 bytes. To ensure bytes are left for [@snapshot] the + * portition is futher limited to 9 bytes. For 2.6.27 and + * newer kernels this limit is set to MAXNAMELEN. + * + * / + + + * (18) + (1) + (1) */ - +#ifdef HAVE_KOBJ_NAME_LEN + if (strlen(path) > 18) { +#else if (strlen(path) >= MAXNAMELEN) { +#endif /* HAVE_KOBJ_NAME_LEN */ if (why) *why = NAME_ERR_TOOLONG; return (-1); @@ -303,8 +316,22 @@ pool_namecheck(const char *pool, namecheck_err_t *why, char *what) * which is the same as MAXNAMELEN used in the kernel. * If ZPOOL_MAXNAMELEN value is changed, make sure to cleanup all * places using MAXNAMELEN. + * + * When HAVE_KOBJ_NAME_LEN is defined the maximum safe kobject name + * length is 20 bytes. This 20 bytes is broken down as follows to + * provide a maximum safe /[@snapshot] length of only + * 18 bytes. To ensure bytes are left for [@snapshot] the + * portition is futher limited to 8 bytes. For 2.6.27 and + * newer kernels this limit is set to MAXNAMELEN. + * + * / + + + * (18) + (1) + (1) */ +#ifdef HAVE_KOBJ_NAME_LEN + if (strlen(pool) > 8) { +#else if (strlen(pool) >= MAXNAMELEN) { +#endif /* HAVE_KOBJ_NAME_LEN */ if (why) *why = NAME_ERR_TOOLONG; return (-1); @@ -343,3 +370,9 @@ pool_namecheck(const char *pool, namecheck_err_t *why, char *what) return (0); } + +#if defined(_KERNEL) && defined(HAVE_SPL) +EXPORT_SYMBOL(snapshot_namecheck); +EXPORT_SYMBOL(pool_namecheck); +EXPORT_SYMBOL(dataset_namecheck); +#endif