exfat & xfs: Adapt to use next_dirent and shared open_mode_to_access.

This commit is contained in:
Augustin Cavalier 2023-01-27 23:56:03 -05:00
parent 35b40030a7
commit 4133750ca3
4 changed files with 7 additions and 53 deletions

View File

@ -28,23 +28,6 @@ enum inode_type {
};
/*! Converts the open mode, the open flags given to bfs_open(), into
access modes, e.g. since O_RDONLY requires read access to the
file, it will be converted to R_OK.
*/
inline int
open_mode_to_access(int openMode)
{
openMode &= O_RWMASK;
if (openMode == O_RDONLY)
return R_OK;
if (openMode == O_WRONLY)
return W_OK;
return R_OK | W_OK;
}
/*! Reads the volume name from an exfat entry and writes it to
\a name as a UTF-8 char array.

View File

@ -26,6 +26,7 @@
#include <NodeMonitor.h>
#include <StorageDefs.h>
#include <util/AutoLock.h>
#include <file_systems/fs_ops_support.h>
#include "DirectoryIterator.h"
#include "exfat.h"
@ -608,10 +609,8 @@ exfat_read_dir(fs_volume *_volume, fs_vnode *_node, void *_cookie,
dirent->d_dev = volume->ID();
dirent->d_ino = id;
dirent->d_reclen = offsetof(struct dirent, d_name) + length + 1;
bufferSize -= dirent->d_reclen;
dirent = (struct dirent*)((uint8*)dirent + dirent->d_reclen);
dirent = next_dirent(dirent, length, bufferSize);
count++;
}

View File

@ -1,27 +0,0 @@
/*
* Copyright 2001-2009, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2020, Shubham Bhagat, shubhambhagat111@yahoo.com
* This file may be used under the terms of the MIT License.
*/
#ifndef UTILITY_H
#define UTILITY_H
/*! Converts the open mode, the open flags given to xfs_open(), into
access modes, e.g. since O_RDONLY requires read access to the
file, it will be converted to R_OK.
*/
inline int
open_mode_to_access(int openMode)
{
openMode &= O_RWMASK;
if (openMode == O_RDONLY)
return R_OK;
if (openMode == O_WRONLY)
return W_OK;
return R_OK | W_OK;
}
#endif // UTILITY_H

View File

@ -10,14 +10,14 @@
#include "Inode.h"
#include "ShortAttribute.h"
#include "Symlink.h"
#include "Utility.h"
#include "Volume.h"
#include <file_systems/fs_ops_support.h>
#define XFS_IO_SIZE 65536
struct identify_cookie
{
struct identify_cookie {
/* super_block_struct super_block;
* No structure yet implemented.
*/
@ -437,9 +437,8 @@ xfs_read_dir(fs_volume *_volume, fs_vnode *_node, void *_cookie,
buffer->d_dev = volume->ID();
buffer->d_ino = ino;
buffer->d_reclen = offsetof(struct dirent, d_name) + length + 1;
bufferSize -= buffer->d_reclen;
buffer = (struct dirent*)((uint8*)buffer + buffer->d_reclen);
buffer = next_dirent(buffer, length, bufferSize);
count++;
}