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 Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux