[apparmor] [PATCH 1/6] libapparmor: Use directory file descriptor in _aa_dirat_for_each()
Tyler Hicks
tyhicks at canonical.com
Wed Apr 1 17:49:30 UTC 2015
On 2015-03-31 20:52:52, Seth Arnold wrote:
> On Thu, Mar 26, 2015 at 04:47:57PM -0500, Tyler Hicks wrote:
> > The _aa_dirat_for_each() function used the DIR * type for its first
> > parameter. It then switched back and forth between the directory file
> > descriptors, retrieved with dirfd(), and directory streams, retrieved
> > with fdopendir(), when making syscalls and calling the call back
> > function.
> >
> > This patch greatly simplifies the function by simply using directory
> > file descriptors. No functionality is lost since callers can still
> > easily use the function after calling dirfd() to retrieve the underlying
> > file descriptor.
> >
> > Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
>
> I like the gist of this patch but I think the parameter shouldn't be named
> dirfd; if we ever need the dirent.h header back again, this'll cause no
> end of confusion. It'd be safer to just pick a less obvious name, dir_fd
> for example.
Thanks for the review!
The "dirfd" naming convention is used in all of the *at(2) calls:
int faccessat(int dirfd, const char *pathname, int mode, int flags);
int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);
int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags);
int openat(int dirfd, const char *pathname, int flags);
...
That said, I don't mind changing it. I think prefer "dfd" over "dir_fd".
Does that sound good?
Tyler
>
> With a name change,
> Acked-by: Seth Arnold <seth.arnold at canonical.com>
>
> Thanks
> --
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150401/593c5210/attachment-0001.pgp>
More information about the AppArmor
mailing list