Re: [PATCH v4 2/2] fs: Create a generic is_dot_dotdot() utility

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 05, 2024 at 09:36:51AM +0200, Amir Goldstein wrote:
> On Thu, Jan 4, 2024 at 10:55 PM Chuck Lever <cel@xxxxxxxxxx> wrote:
> > diff --git a/include/linux/fs.h b/include/linux/fs.h
> > index 98b7a7a8c42e..53dd58a907e0 100644
> > --- a/include/linux/fs.h
> > +++ b/include/linux/fs.h
> > @@ -2846,6 +2846,19 @@ extern bool path_is_under(const struct path *, const struct path *);
> >
> >  extern char *file_path(struct file *, char *, int);
> >
> > +/**
> > + * is_dot_dotdot - returns true only if @name is "." or ".."
> > + * @name: file name to check
> > + * @len: length of file name, in bytes
> > + *
> > + * Coded for efficiency.
> > + */
> > +static inline bool is_dot_dotdot(const char *name, size_t len)
> > +{
> > +       return len && unlikely(name[0] == '.') &&
> > +               (len < 2 || (len == 2 && name[1] == '.'));
> > +}
> > +
> 
> Looking back at the version that I suggested, (len < 2
> here is silly and should be (len == 1 || ...

Yeah, probably. I'm trying to stick to copying code without changing
it at the same time; that's the usual guideline.


> But let's wait for inputs from other developers on this helper,
> especially Al.

Fair, will do.


-- 
Chuck Lever




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux