2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 14:25:52 +00:00

libapparmor: Use directory file descriptor in _aa_dirat_for_each()

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@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
Tyler Hicks
2015-06-15 15:11:51 -05:00
parent 014e079261
commit 86de47d08a
8 changed files with 67 additions and 101 deletions

View File

@@ -16,7 +16,6 @@
* Ltd.
*/
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
@@ -29,10 +28,10 @@
#include "lib.h"
#include "parser.h"
int dirat_for_each(DIR *dir, const char *name, void *data,
int (* cb)(DIR *, const char *, struct stat *, void *))
int dirat_for_each(int dirfd, const char *name, void *data,
int (* cb)(int, const char *, struct stat *, void *))
{
int retval = _aa_dirat_for_each(dir, name, data, cb);
int retval = _aa_dirat_for_each(dirfd, name, data, cb);
if (retval)
PDEBUG("dirat_for_each failed: %m\n");