Use lib_get_pathbuffer instead of stack variables
Summary: Modified the usage logic, mainly introduced lib_get_pathbuffer and lib_put_pathbuffer Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
parent
0c9203b48e
commit
2cf26036a5
33 changed files with 545 additions and 111 deletions
|
|
@ -31,6 +31,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <nuttx/timers/timer.h>
|
#include <nuttx/timers/timer.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
#include "esp_irq.h"
|
#include "esp_irq.h"
|
||||||
#include "esp_timer.h"
|
#include "esp_timer.h"
|
||||||
|
|
@ -508,7 +509,7 @@ IRAM_ATTR static int esp_timer_isr(int irq, void *context, void *arg)
|
||||||
int esp_timer_initialize(uint32_t timer_id)
|
int esp_timer_initialize(uint32_t timer_id)
|
||||||
{
|
{
|
||||||
struct esp_timer_lowerhalf_s *lower = NULL;
|
struct esp_timer_lowerhalf_s *lower = NULL;
|
||||||
char devpath[PATH_MAX];
|
FAR char *devpath;
|
||||||
uint32_t group_num;
|
uint32_t group_num;
|
||||||
uint32_t timer_num;
|
uint32_t timer_num;
|
||||||
|
|
||||||
|
|
@ -539,7 +540,13 @@ int esp_timer_initialize(uint32_t timer_id)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(devpath, sizeof(devpath), "/dev/timer%" PRIu32, timer_id);
|
devpath = lib_get_pathbuffer();
|
||||||
|
if (devpath == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(devpath, PATH_MAX, "/dev/timer%" PRIu32, timer_id);
|
||||||
|
|
||||||
/* Initialize the elements of lower half state structure */
|
/* Initialize the elements of lower half state structure */
|
||||||
|
|
||||||
|
|
@ -562,9 +569,11 @@ int esp_timer_initialize(uint32_t timer_id)
|
||||||
* indicate the failure (implying the non-unique devpath).
|
* indicate the failure (implying the non-unique devpath).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
lib_put_pathbuffer(devpath);
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lib_put_pathbuffer(devpath);
|
||||||
esp_setup_irq(lower->source,
|
esp_setup_irq(lower->source,
|
||||||
ESP_IRQ_PRIORITY_DEFAULT,
|
ESP_IRQ_PRIORITY_DEFAULT,
|
||||||
ESP_IRQ_TRIGGER_LEVEL);
|
ESP_IRQ_TRIGGER_LEVEL);
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
#include <nuttx/input/aw86225.h>
|
#include <nuttx/input/aw86225.h>
|
||||||
#include <nuttx/input/ff.h>
|
#include <nuttx/input/ff.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
#include "aw86225_reg.h"
|
#include "aw86225_reg.h"
|
||||||
#include "aw86225_internal.h"
|
#include "aw86225_internal.h"
|
||||||
|
|
@ -369,14 +370,21 @@ static int aw86225_i2c_write_bits(FAR struct aw86225 *aw86225,
|
||||||
static int aw86225_request_firmware(FAR struct aw86225_firmware *fw,
|
static int aw86225_request_firmware(FAR struct aw86225_firmware *fw,
|
||||||
FAR const char *filename)
|
FAR const char *filename)
|
||||||
{
|
{
|
||||||
char file_path[PATH_MAX];
|
FAR char *file_path;
|
||||||
struct file file;
|
struct file file;
|
||||||
size_t file_size;
|
size_t file_size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
snprintf(file_path, sizeof(file_path), "%s/%s", CONFIG_FF_RTP_FILE_PATH,
|
file_path = lib_get_pathbuffer();
|
||||||
|
if (file_path == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(file_path, PATH_MAX, "%s/%s", CONFIG_FF_RTP_FILE_PATH,
|
||||||
filename);
|
filename);
|
||||||
ret = file_open(&file, file_path, O_RDONLY);
|
ret = file_open(&file, file_path, O_RDONLY);
|
||||||
|
lib_put_pathbuffer(file_path);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ierr("open file failed");
|
ierr("open file failed");
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
#include <nuttx/nuttx.h>
|
#include <nuttx/nuttx.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/mtd/mtd.h>
|
#include <nuttx/mtd/mtd.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
#include <dhara/map.h>
|
#include <dhara/map.h>
|
||||||
#include <dhara/nand.h>
|
#include <dhara/nand.h>
|
||||||
|
|
@ -785,7 +786,8 @@ err:
|
||||||
|
|
||||||
int dhara_initialize(int minor, FAR struct mtd_dev_s *mtd)
|
int dhara_initialize(int minor, FAR struct mtd_dev_s *mtd)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
|
int ret;
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FEATURES
|
#ifdef CONFIG_DEBUG_FEATURES
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
|
|
@ -796,8 +798,16 @@ int dhara_initialize(int minor, FAR struct mtd_dev_s *mtd)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
/* Do the real work by dhara_mtdblock_initialize_by_path */
|
/* Do the real work by dhara_mtdblock_initialize_by_path */
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "/dev/mtdblock%d", minor);
|
snprintf(path, PATH_MAX, "/dev/mtdblock%d", minor);
|
||||||
return dhara_initialize_by_path(path, mtd);
|
ret = dhara_initialize_by_path(path, mtd);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include <nuttx/circbuf.h>
|
#include <nuttx/circbuf.h>
|
||||||
#include <nuttx/sensors/sensor.h>
|
#include <nuttx/sensors/sensor.h>
|
||||||
#include <nuttx/sensors/gnss.h>
|
#include <nuttx/sensors/gnss.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
@ -715,7 +716,7 @@ int gnss_register(FAR struct gnss_lowerhalf_s *lower, int devno,
|
||||||
{
|
{
|
||||||
FAR struct gnss_upperhalf_s *upper;
|
FAR struct gnss_upperhalf_s *upper;
|
||||||
FAR struct gnss_sensor_s *dev;
|
FAR struct gnss_sensor_s *dev;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
upper = kmm_zalloc(sizeof(struct gnss_upperhalf_s));
|
upper = kmm_zalloc(sizeof(struct gnss_upperhalf_s));
|
||||||
|
|
@ -724,6 +725,13 @@ int gnss_register(FAR struct gnss_lowerhalf_s *lower, int devno,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
kmm_free(upper);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
lower->push_data = gnss_push_data;
|
lower->push_data = gnss_push_data;
|
||||||
lower->push_event = gnss_push_event;
|
lower->push_event = gnss_push_event;
|
||||||
lower->priv = upper;
|
lower->priv = upper;
|
||||||
|
|
@ -814,6 +822,7 @@ int gnss_register(FAR struct gnss_lowerhalf_s *lower, int devno,
|
||||||
goto driver_err;
|
goto driver_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
driver_err:
|
driver_err:
|
||||||
|
|
@ -832,6 +841,7 @@ gnss_err:
|
||||||
nxmutex_destroy(&upper->lock);
|
nxmutex_destroy(&upper->lock);
|
||||||
nxmutex_destroy(&upper->bufferlock);
|
nxmutex_destroy(&upper->bufferlock);
|
||||||
nxsem_destroy(&upper->buffersem);
|
nxsem_destroy(&upper->buffersem);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
kmm_free(upper);
|
kmm_free(upper);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -853,7 +863,13 @@ gnss_err:
|
||||||
void gnss_unregister(FAR struct gnss_lowerhalf_s *lower, int devno)
|
void gnss_unregister(FAR struct gnss_lowerhalf_s *lower, int devno)
|
||||||
{
|
{
|
||||||
FAR struct gnss_upperhalf_s *upper = lower->priv;
|
FAR struct gnss_upperhalf_s *upper = lower->priv;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sensor_unregister(&upper->dev[GNSS_IDX].lower, devno);
|
sensor_unregister(&upper->dev[GNSS_IDX].lower, devno);
|
||||||
sensor_unregister(&upper->dev[GNSS_SATELLITE_IDX].lower, devno);
|
sensor_unregister(&upper->dev[GNSS_SATELLITE_IDX].lower, devno);
|
||||||
|
|
@ -864,5 +880,6 @@ void gnss_unregister(FAR struct gnss_lowerhalf_s *lower, int devno)
|
||||||
unregister_driver(path);
|
unregister_driver(path);
|
||||||
nxsem_destroy(&upper->buffersem);
|
nxsem_destroy(&upper->buffersem);
|
||||||
circbuf_uninit(&upper->buffer);
|
circbuf_uninit(&upper->buffer);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
kmm_free(upper);
|
kmm_free(upper);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
#include <nuttx/circbuf.h>
|
#include <nuttx/circbuf.h>
|
||||||
#include <nuttx/mutex.h>
|
#include <nuttx/mutex.h>
|
||||||
#include <nuttx/sensors/sensor.h>
|
#include <nuttx/sensors/sensor.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
|
|
@ -1240,16 +1241,25 @@ void sensor_remap_vector_raw16(FAR const int16_t *in, FAR int16_t *out,
|
||||||
|
|
||||||
int sensor_register(FAR struct sensor_lowerhalf_s *lower, int devno)
|
int sensor_register(FAR struct sensor_lowerhalf_s *lower, int devno)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
|
int ret;
|
||||||
|
|
||||||
DEBUGASSERT(lower != NULL);
|
DEBUGASSERT(lower != NULL);
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, DEVNAME_FMT,
|
snprintf(path, PATH_MAX, DEVNAME_FMT,
|
||||||
g_sensor_meta[lower->type].name,
|
g_sensor_meta[lower->type].name,
|
||||||
lower->uncalibrated ? DEVNAME_UNCAL : "",
|
lower->uncalibrated ? DEVNAME_UNCAL : "",
|
||||||
devno);
|
devno);
|
||||||
return sensor_custom_register(lower, path,
|
ret = sensor_custom_register(lower, path,
|
||||||
g_sensor_meta[lower->type].esize);
|
g_sensor_meta[lower->type].esize);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
@ -1381,13 +1391,20 @@ rpmsg_err:
|
||||||
|
|
||||||
void sensor_unregister(FAR struct sensor_lowerhalf_s *lower, int devno)
|
void sensor_unregister(FAR struct sensor_lowerhalf_s *lower, int devno)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, DEVNAME_FMT,
|
snprintf(path, PATH_MAX, DEVNAME_FMT,
|
||||||
g_sensor_meta[lower->type].name,
|
g_sensor_meta[lower->type].name,
|
||||||
lower->uncalibrated ? DEVNAME_UNCAL : "",
|
lower->uncalibrated ? DEVNAME_UNCAL : "",
|
||||||
devno);
|
devno);
|
||||||
sensor_custom_unregister(lower, path);
|
sensor_custom_unregister(lower, path);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
#include <nuttx/spawn.h>
|
#include <nuttx/spawn.h>
|
||||||
#include <nuttx/spinlock.h>
|
#include <nuttx/spinlock.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
#ifdef CONFIG_FDSAN
|
#ifdef CONFIG_FDSAN
|
||||||
# include <android/fdsan.h>
|
# include <android/fdsan.h>
|
||||||
|
|
@ -383,6 +384,7 @@ void files_initlist(FAR struct filelist *list)
|
||||||
#ifdef CONFIG_SCHED_DUMP_ON_EXIT
|
#ifdef CONFIG_SCHED_DUMP_ON_EXIT
|
||||||
void files_dumplist(FAR struct filelist *list)
|
void files_dumplist(FAR struct filelist *list)
|
||||||
{
|
{
|
||||||
|
FAR char *path;
|
||||||
int count = files_countlist(list);
|
int count = files_countlist(list);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
@ -394,10 +396,15 @@ void files_dumplist(FAR struct filelist *list)
|
||||||
"PID", "FD", "FLAGS", "TYPE", "POS", "PATH"
|
"PID", "FD", "FLAGS", "TYPE", "POS", "PATH"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
FAR struct file *filep = files_fget(list, i);
|
FAR struct file *filep = files_fget(list, i);
|
||||||
char path[PATH_MAX];
|
|
||||||
|
|
||||||
#if CONFIG_FS_BACKTRACE > 0
|
#if CONFIG_FS_BACKTRACE > 0
|
||||||
char buf[BACKTRACE_BUFFER_SIZE(CONFIG_FS_BACKTRACE)];
|
char buf[BACKTRACE_BUFFER_SIZE(CONFIG_FS_BACKTRACE)];
|
||||||
|
|
@ -433,6 +440,8 @@ void files_dumplist(FAR struct filelist *list)
|
||||||
);
|
);
|
||||||
fs_putfilep(filep);
|
fs_putfilep(filep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/wqueue.h>
|
#include <nuttx/wqueue.h>
|
||||||
#include <nuttx/fs/automount.h>
|
#include <nuttx/fs/automount.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
#ifdef CONFIG_FS_AUTOMOUNTER_DRIVER
|
#ifdef CONFIG_FS_AUTOMOUNTER_DRIVER
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
|
|
@ -809,7 +810,11 @@ FAR void *automount_initialize(FAR const struct automount_lower_s *lower)
|
||||||
FAR struct automounter_state_s *priv;
|
FAR struct automounter_state_s *priv;
|
||||||
int ret;
|
int ret;
|
||||||
#ifdef CONFIG_FS_AUTOMOUNTER_DRIVER
|
#ifdef CONFIG_FS_AUTOMOUNTER_DRIVER
|
||||||
char devpath[PATH_MAX];
|
FAR char *devpath = lib_get_pathbuffer();
|
||||||
|
if (devpath == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif /* CONFIG_FS_AUTOMOUNTER_DRIVER */
|
#endif /* CONFIG_FS_AUTOMOUNTER_DRIVER */
|
||||||
|
|
||||||
finfo("lower=%p\n", lower);
|
finfo("lower=%p\n", lower);
|
||||||
|
|
@ -853,10 +858,11 @@ FAR void *automount_initialize(FAR const struct automount_lower_s *lower)
|
||||||
|
|
||||||
/* Register driver */
|
/* Register driver */
|
||||||
|
|
||||||
snprintf(devpath, sizeof(devpath),
|
snprintf(devpath, PATH_MAX,
|
||||||
CONFIG_FS_AUTOMOUNTER_VFS_PATH "%s", lower->mountpoint);
|
CONFIG_FS_AUTOMOUNTER_VFS_PATH "%s", lower->mountpoint);
|
||||||
|
|
||||||
ret = register_driver(devpath, &g_automount_fops, 0444, priv);
|
ret = register_driver(devpath, &g_automount_fops, 0444, priv);
|
||||||
|
lib_put_pathbuffer(devpath);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: Failed to register automount driver: %d\n", ret);
|
ferr("ERROR: Failed to register automount driver: %d\n", ret);
|
||||||
|
|
@ -913,12 +919,17 @@ void automount_uninitialize(FAR void *handle)
|
||||||
#ifdef CONFIG_FS_AUTOMOUNTER_DRIVER
|
#ifdef CONFIG_FS_AUTOMOUNTER_DRIVER
|
||||||
if (priv->registered)
|
if (priv->registered)
|
||||||
{
|
{
|
||||||
char devpath[PATH_MAX];
|
FAR char *devpath = lib_get_pathbuffer();
|
||||||
|
if (devpath == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(devpath, sizeof(devpath),
|
snprintf(devpath, PATH_MAX,
|
||||||
CONFIG_FS_AUTOMOUNTER_VFS_PATH "%s", lower->mountpoint);
|
CONFIG_FS_AUTOMOUNTER_VFS_PATH "%s", lower->mountpoint);
|
||||||
|
|
||||||
unregister_driver(devpath);
|
unregister_driver(devpath);
|
||||||
|
lib_put_pathbuffer(devpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxmutex_destroy(&priv->lock);
|
nxmutex_destroy(&priv->lock);
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,15 @@ static void register_partition(FAR struct partition_s *part, FAR void *arg)
|
||||||
{
|
{
|
||||||
FAR struct partition_register_s *reg = arg;
|
FAR struct partition_register_s *reg = arg;
|
||||||
FAR struct partition_state_s *state = reg->state;
|
FAR struct partition_state_s *state = reg->state;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "%s/%s", reg->dir, part->name);
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(path, PATH_MAX, "%s/%s", reg->dir, part->name);
|
||||||
if (state->blk != NULL)
|
if (state->blk != NULL)
|
||||||
{
|
{
|
||||||
register_partition_with_inode(path, 0660, state->blk,
|
register_partition_with_inode(path, 0660, state->blk,
|
||||||
|
|
@ -108,6 +114,8 @@ static void register_partition(FAR struct partition_s *part, FAR void *arg)
|
||||||
part->firstblock, part->nblocks);
|
part->firstblock, part->nblocks);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/mm/mm.h>
|
#include <nuttx/mm/mm.h>
|
||||||
#include <nuttx/queue.h>
|
#include <nuttx/queue.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
#include "fs_heap.h"
|
#include "fs_heap.h"
|
||||||
|
|
||||||
|
|
@ -1252,7 +1253,7 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
||||||
{
|
{
|
||||||
FAR struct task_group_s *group = tcb->group;
|
FAR struct task_group_s *group = tcb->group;
|
||||||
FAR struct file *filep;
|
FAR struct file *filep;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
size_t remaining;
|
size_t remaining;
|
||||||
size_t linesize;
|
size_t linesize;
|
||||||
size_t copysize;
|
size_t copysize;
|
||||||
|
|
@ -1292,6 +1293,12 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
||||||
return totalsize;
|
return totalsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return totalsize;
|
||||||
|
}
|
||||||
|
|
||||||
/* Examine each open file descriptor */
|
/* Examine each open file descriptor */
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
|
|
@ -1336,10 +1343,12 @@ static ssize_t proc_groupfd(FAR struct proc_file_s *procfile,
|
||||||
|
|
||||||
if (totalsize >= buflen)
|
if (totalsize >= buflen)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return totalsize;
|
return totalsize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return totalsize;
|
return totalsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ static int rpmsgfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||||
FAR struct inode *inode;
|
FAR struct inode *inode;
|
||||||
FAR struct rpmsgfs_mountpt_s *fs;
|
FAR struct rpmsgfs_mountpt_s *fs;
|
||||||
FAR struct rpmsgfs_ofile_s *hf;
|
FAR struct rpmsgfs_ofile_s *hf;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
@ -298,11 +298,18 @@ static int rpmsgfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||||
|
|
||||||
DEBUGASSERT(fs != NULL);
|
DEBUGASSERT(fs != NULL);
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
/* Take the lock */
|
/* Take the lock */
|
||||||
|
|
||||||
ret = nxmutex_lock(&fs->fs_lock);
|
ret = nxmutex_lock(&fs->fs_lock);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -317,7 +324,7 @@ static int rpmsgfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||||
|
|
||||||
/* Append to the host's root directory */
|
/* Append to the host's root directory */
|
||||||
|
|
||||||
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
rpmsgfs_mkpath(fs, relpath, path, PATH_MAX);
|
||||||
|
|
||||||
/* Try to open the file in the host file system */
|
/* Try to open the file in the host file system */
|
||||||
|
|
||||||
|
|
@ -370,6 +377,7 @@ errout_with_buffer:
|
||||||
|
|
||||||
errout_with_lock:
|
errout_with_lock:
|
||||||
nxmutex_unlock(&fs->fs_lock);
|
nxmutex_unlock(&fs->fs_lock);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
if (ret == -EINVAL)
|
if (ret == -EINVAL)
|
||||||
{
|
{
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
|
|
@ -867,7 +875,7 @@ static int rpmsgfs_opendir(FAR struct inode *mountpt,
|
||||||
{
|
{
|
||||||
FAR struct rpmsgfs_mountpt_s *fs;
|
FAR struct rpmsgfs_mountpt_s *fs;
|
||||||
FAR struct rpmsgfs_dir_s *rdir;
|
FAR struct rpmsgfs_dir_s *rdir;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
@ -883,6 +891,13 @@ static int rpmsgfs_opendir(FAR struct inode *mountpt,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
fs_heap_free(rdir);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
/* Take the lock */
|
/* Take the lock */
|
||||||
|
|
||||||
ret = nxmutex_lock(&fs->fs_lock);
|
ret = nxmutex_lock(&fs->fs_lock);
|
||||||
|
|
@ -893,7 +908,7 @@ static int rpmsgfs_opendir(FAR struct inode *mountpt,
|
||||||
|
|
||||||
/* Append to the host's root directory */
|
/* Append to the host's root directory */
|
||||||
|
|
||||||
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
rpmsgfs_mkpath(fs, relpath, path, PATH_MAX);
|
||||||
|
|
||||||
/* Call the host's opendir function */
|
/* Call the host's opendir function */
|
||||||
|
|
||||||
|
|
@ -906,12 +921,14 @@ static int rpmsgfs_opendir(FAR struct inode *mountpt,
|
||||||
|
|
||||||
*dir = (FAR struct fs_dirent_s *)rdir;
|
*dir = (FAR struct fs_dirent_s *)rdir;
|
||||||
nxmutex_unlock(&fs->fs_lock);
|
nxmutex_unlock(&fs->fs_lock);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_lock:
|
errout_with_lock:
|
||||||
nxmutex_unlock(&fs->fs_lock);
|
nxmutex_unlock(&fs->fs_lock);
|
||||||
|
|
||||||
errout_with_rdir:
|
errout_with_rdir:
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
fs_heap_free(rdir);
|
fs_heap_free(rdir);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -1244,7 +1261,7 @@ static int rpmsgfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
|
||||||
static int rpmsgfs_unlink(FAR struct inode *mountpt, FAR const char *relpath)
|
static int rpmsgfs_unlink(FAR struct inode *mountpt, FAR const char *relpath)
|
||||||
{
|
{
|
||||||
FAR struct rpmsgfs_mountpt_s *fs;
|
FAR struct rpmsgfs_mountpt_s *fs;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
@ -1255,21 +1272,29 @@ static int rpmsgfs_unlink(FAR struct inode *mountpt, FAR const char *relpath)
|
||||||
|
|
||||||
fs = mountpt->i_private;
|
fs = mountpt->i_private;
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
ret = nxmutex_lock(&fs->fs_lock);
|
ret = nxmutex_lock(&fs->fs_lock);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append to the host's root directory */
|
/* Append to the host's root directory */
|
||||||
|
|
||||||
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
rpmsgfs_mkpath(fs, relpath, path, PATH_MAX);
|
||||||
|
|
||||||
/* Call the host fs to perform the unlink */
|
/* Call the host fs to perform the unlink */
|
||||||
|
|
||||||
ret = rpmsgfs_client_unlink(fs->handle, path);
|
ret = rpmsgfs_client_unlink(fs->handle, path);
|
||||||
|
|
||||||
nxmutex_unlock(&fs->fs_lock);
|
nxmutex_unlock(&fs->fs_lock);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1284,7 +1309,7 @@ static int rpmsgfs_mkdir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||||
mode_t mode)
|
mode_t mode)
|
||||||
{
|
{
|
||||||
FAR struct rpmsgfs_mountpt_s *fs;
|
FAR struct rpmsgfs_mountpt_s *fs;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
@ -1295,21 +1320,29 @@ static int rpmsgfs_mkdir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||||
|
|
||||||
fs = mountpt->i_private;
|
fs = mountpt->i_private;
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
ret = nxmutex_lock(&fs->fs_lock);
|
ret = nxmutex_lock(&fs->fs_lock);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append to the host's root directory */
|
/* Append to the host's root directory */
|
||||||
|
|
||||||
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
rpmsgfs_mkpath(fs, relpath, path, PATH_MAX);
|
||||||
|
|
||||||
/* Call the host FS to do the mkdir */
|
/* Call the host FS to do the mkdir */
|
||||||
|
|
||||||
ret = rpmsgfs_client_mkdir(fs->handle, path, mode);
|
ret = rpmsgfs_client_mkdir(fs->handle, path, mode);
|
||||||
|
|
||||||
nxmutex_unlock(&fs->fs_lock);
|
nxmutex_unlock(&fs->fs_lock);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1323,7 +1356,7 @@ static int rpmsgfs_mkdir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||||
int rpmsgfs_rmdir(FAR struct inode *mountpt, FAR const char *relpath)
|
int rpmsgfs_rmdir(FAR struct inode *mountpt, FAR const char *relpath)
|
||||||
{
|
{
|
||||||
FAR struct rpmsgfs_mountpt_s *fs;
|
FAR struct rpmsgfs_mountpt_s *fs;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
@ -1336,21 +1369,29 @@ int rpmsgfs_rmdir(FAR struct inode *mountpt, FAR const char *relpath)
|
||||||
|
|
||||||
/* Take the lock */
|
/* Take the lock */
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
ret = nxmutex_lock(&fs->fs_lock);
|
ret = nxmutex_lock(&fs->fs_lock);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append to the host's root directory */
|
/* Append to the host's root directory */
|
||||||
|
|
||||||
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
rpmsgfs_mkpath(fs, relpath, path, PATH_MAX);
|
||||||
|
|
||||||
/* Call the host FS to do the mkdir */
|
/* Call the host FS to do the mkdir */
|
||||||
|
|
||||||
ret = rpmsgfs_client_rmdir(fs->handle, path);
|
ret = rpmsgfs_client_rmdir(fs->handle, path);
|
||||||
|
|
||||||
nxmutex_unlock(&fs->fs_lock);
|
nxmutex_unlock(&fs->fs_lock);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1365,10 +1406,23 @@ int rpmsgfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
|
||||||
FAR const char *newrelpath)
|
FAR const char *newrelpath)
|
||||||
{
|
{
|
||||||
FAR struct rpmsgfs_mountpt_s *fs;
|
FAR struct rpmsgfs_mountpt_s *fs;
|
||||||
char oldpath[PATH_MAX];
|
FAR char *oldpath;
|
||||||
char newpath[PATH_MAX];
|
FAR char *newpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
oldpath = lib_get_pathbuffer();
|
||||||
|
if (oldpath == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
newpath = lib_get_pathbuffer();
|
||||||
|
if (newpath == NULL)
|
||||||
|
{
|
||||||
|
lib_put_pathbuffer(oldpath);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
||||||
DEBUGASSERT(mountpt && mountpt->i_private);
|
DEBUGASSERT(mountpt && mountpt->i_private);
|
||||||
|
|
@ -1380,21 +1434,25 @@ int rpmsgfs_rename(FAR struct inode *mountpt, FAR const char *oldrelpath,
|
||||||
ret = nxmutex_lock(&fs->fs_lock);
|
ret = nxmutex_lock(&fs->fs_lock);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(oldpath);
|
||||||
|
lib_put_pathbuffer(newpath);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append to the host's root directory */
|
/* Append to the host's root directory */
|
||||||
|
|
||||||
strlcpy(oldpath, fs->fs_root, sizeof(oldpath));
|
strlcpy(oldpath, fs->fs_root, PATH_MAX);
|
||||||
strlcat(oldpath, oldrelpath, sizeof(oldpath));
|
strlcat(oldpath, oldrelpath, PATH_MAX);
|
||||||
strlcpy(newpath, fs->fs_root, sizeof(newpath));
|
strlcpy(newpath, fs->fs_root, PATH_MAX);
|
||||||
strlcat(newpath, newrelpath, sizeof(newpath));
|
strlcat(newpath, newrelpath, PATH_MAX);
|
||||||
|
|
||||||
/* Call the host FS to do the mkdir */
|
/* Call the host FS to do the mkdir */
|
||||||
|
|
||||||
ret = rpmsgfs_client_rename(fs->handle, oldpath, newpath);
|
ret = rpmsgfs_client_rename(fs->handle, oldpath, newpath);
|
||||||
|
|
||||||
nxmutex_unlock(&fs->fs_lock);
|
nxmutex_unlock(&fs->fs_lock);
|
||||||
|
lib_put_pathbuffer(oldpath);
|
||||||
|
lib_put_pathbuffer(newpath);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1409,7 +1467,7 @@ static int rpmsgfs_stat(FAR struct inode *mountpt, FAR const char *relpath,
|
||||||
FAR struct stat *buf)
|
FAR struct stat *buf)
|
||||||
{
|
{
|
||||||
FAR struct rpmsgfs_mountpt_s *fs;
|
FAR struct rpmsgfs_mountpt_s *fs;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
@ -1420,21 +1478,29 @@ static int rpmsgfs_stat(FAR struct inode *mountpt, FAR const char *relpath,
|
||||||
|
|
||||||
fs = mountpt->i_private;
|
fs = mountpt->i_private;
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
ret = nxmutex_lock(&fs->fs_lock);
|
ret = nxmutex_lock(&fs->fs_lock);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append to the host's root directory */
|
/* Append to the host's root directory */
|
||||||
|
|
||||||
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
rpmsgfs_mkpath(fs, relpath, path, PATH_MAX);
|
||||||
|
|
||||||
/* Call the host FS to do the stat operation */
|
/* Call the host FS to do the stat operation */
|
||||||
|
|
||||||
ret = rpmsgfs_client_stat(fs->handle, path, buf);
|
ret = rpmsgfs_client_stat(fs->handle, path, buf);
|
||||||
|
|
||||||
nxmutex_unlock(&fs->fs_lock);
|
nxmutex_unlock(&fs->fs_lock);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1449,7 +1515,7 @@ static int rpmsgfs_chstat(FAR struct inode *mountpt, FAR const char *relpath,
|
||||||
FAR const struct stat *buf, int flags)
|
FAR const struct stat *buf, int flags)
|
||||||
{
|
{
|
||||||
FAR struct rpmsgfs_mountpt_s *fs;
|
FAR struct rpmsgfs_mountpt_s *fs;
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
|
@ -1460,20 +1526,28 @@ static int rpmsgfs_chstat(FAR struct inode *mountpt, FAR const char *relpath,
|
||||||
|
|
||||||
fs = mountpt->i_private;
|
fs = mountpt->i_private;
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
ret = nxmutex_lock(&fs->fs_lock);
|
ret = nxmutex_lock(&fs->fs_lock);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append to the host's root directory */
|
/* Append to the host's root directory */
|
||||||
|
|
||||||
rpmsgfs_mkpath(fs, relpath, path, sizeof(path));
|
rpmsgfs_mkpath(fs, relpath, path, PATH_MAX);
|
||||||
|
|
||||||
/* Call the host FS to do the chstat operation */
|
/* Call the host FS to do the chstat operation */
|
||||||
|
|
||||||
ret = rpmsgfs_client_chstat(fs->handle, path, buf, flags);
|
ret = rpmsgfs_client_chstat(fs->handle, path, buf, flags);
|
||||||
|
|
||||||
nxmutex_unlock(&fs->fs_lock);
|
nxmutex_unlock(&fs->fs_lock);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1603,12 +1603,8 @@ int v9fs_client_init(FAR struct v9fs_client_s *client,
|
||||||
FAR const char *data)
|
FAR const char *data)
|
||||||
{
|
{
|
||||||
FAR const char *options;
|
FAR const char *options;
|
||||||
|
FAR char *aname;
|
||||||
char transport[NAME_MAX];
|
char transport[NAME_MAX];
|
||||||
char aname[PATH_MAX] =
|
|
||||||
{
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
char uname[NAME_MAX] =
|
char uname[NAME_MAX] =
|
||||||
{
|
{
|
||||||
0
|
0
|
||||||
|
|
@ -1617,6 +1613,14 @@ int v9fs_client_init(FAR struct v9fs_client_s *client,
|
||||||
size_t length;
|
size_t length;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
aname = lib_get_pathbuffer();
|
||||||
|
if (aname == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
aname[0] = '\0';
|
||||||
|
|
||||||
/* Parse commandline */
|
/* Parse commandline */
|
||||||
|
|
||||||
options = data;
|
options = data;
|
||||||
|
|
@ -1657,6 +1661,7 @@ int v9fs_client_init(FAR struct v9fs_client_s *client,
|
||||||
ret = v9fs_transport_create(&client->transport, transport, data);
|
ret = v9fs_transport_create(&client->transport, transport, data);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(aname);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1664,6 +1669,7 @@ int v9fs_client_init(FAR struct v9fs_client_s *client,
|
||||||
if (client->fids == NULL)
|
if (client->fids == NULL)
|
||||||
{
|
{
|
||||||
v9fs_transport_destroy(client->transport);
|
v9fs_transport_destroy(client->transport);
|
||||||
|
lib_put_pathbuffer(aname);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1687,12 +1693,14 @@ int v9fs_client_init(FAR struct v9fs_client_s *client,
|
||||||
|
|
||||||
client->root_fid = ret;
|
client->root_fid = ret;
|
||||||
client->tag_id = 1;
|
client->tag_id = 1;
|
||||||
|
lib_put_pathbuffer(aname);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
v9fs_transport_destroy(client->transport);
|
v9fs_transport_destroy(client->transport);
|
||||||
nxmutex_destroy(&client->lock);
|
nxmutex_destroy(&client->lock);
|
||||||
idr_destroy(client->fids);
|
idr_destroy(client->fids);
|
||||||
|
lib_put_pathbuffer(aname);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
#include "inode/inode.h"
|
#include "inode/inode.h"
|
||||||
#include "fs_heap.h"
|
#include "fs_heap.h"
|
||||||
|
|
@ -583,9 +584,15 @@ int dir_allocate(FAR struct file *filep, FAR const char *relpath)
|
||||||
{
|
{
|
||||||
FAR struct fs_dirent_s *dir;
|
FAR struct fs_dirent_s *dir;
|
||||||
FAR struct inode *inode = filep->f_inode;
|
FAR struct inode *inode = filep->f_inode;
|
||||||
char path_prefix[PATH_MAX];
|
FAR char *path_prefix;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
path_prefix = lib_get_pathbuffer();
|
||||||
|
if (path_prefix == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
/* Is this a node in the pseudo filesystem? Or a mountpoint? */
|
/* Is this a node in the pseudo filesystem? Or a mountpoint? */
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||||
|
|
@ -596,6 +603,7 @@ int dir_allocate(FAR struct file *filep, FAR const char *relpath)
|
||||||
ret = open_mountpoint(inode, relpath, &dir);
|
ret = open_mountpoint(inode, relpath, &dir);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(path_prefix);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -605,20 +613,23 @@ int dir_allocate(FAR struct file *filep, FAR const char *relpath)
|
||||||
ret = open_pseudodir(inode, &dir);
|
ret = open_pseudodir(inode, &dir);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(path_prefix);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inode_getpath(inode, path_prefix, sizeof(path_prefix));
|
inode_getpath(inode, path_prefix, PATH_MAX);
|
||||||
ret = fs_heap_asprintf(&dir->fd_path, "%s%s/", path_prefix, relpath);
|
ret = fs_heap_asprintf(&dir->fd_path, "%s%s/", path_prefix, relpath);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
dir->fd_path = NULL;
|
dir->fd_path = NULL;
|
||||||
|
lib_put_pathbuffer(path_prefix);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
filep->f_inode = &g_dir_inode;
|
filep->f_inode = &g_dir_inode;
|
||||||
filep->f_priv = dir;
|
filep->f_priv = dir;
|
||||||
inode_addref(&g_dir_inode);
|
inode_addref(&g_dir_inode);
|
||||||
|
lib_put_pathbuffer(path_prefix);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ nl_catd catopen(FAR const char *name, int oflag)
|
||||||
FAR const char *lang;
|
FAR const char *lang;
|
||||||
FAR const char *p;
|
FAR const char *p;
|
||||||
FAR const char *z;
|
FAR const char *z;
|
||||||
|
FAR char *buf;
|
||||||
|
|
||||||
if (strchr(name, '/'))
|
if (strchr(name, '/'))
|
||||||
{
|
{
|
||||||
|
|
@ -195,9 +196,15 @@ nl_catd catopen(FAR const char *name, int oflag)
|
||||||
lang = "";
|
lang = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf = lib_get_pathbuffer();
|
||||||
|
if (buf == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return MAP_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
for (p = path; *p; p = z)
|
for (p = path; *p; p = z)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
|
||||||
nl_catd catd;
|
nl_catd catd;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
|
@ -261,7 +268,7 @@ nl_catd catopen(FAR const char *name, int oflag)
|
||||||
l = 1;
|
l = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v == NULL || i + l >= sizeof(buf))
|
if (v == NULL || i + l >= PATH_MAX)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -286,10 +293,12 @@ nl_catd catopen(FAR const char *name, int oflag)
|
||||||
catd = catmap(i ? buf : name);
|
catd = catmap(i ? buf : name);
|
||||||
if (catd != MAP_FAILED)
|
if (catd != MAP_FAILED)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(buf);
|
||||||
return catd;
|
return catd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lib_put_pathbuffer(buf);
|
||||||
set_errno(ENOENT);
|
set_errno(ENOENT);
|
||||||
return MAP_FAILED;
|
return MAP_FAILED;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -549,9 +549,9 @@ FAR char *dcngettext(FAR const char *domainname,
|
||||||
{
|
{
|
||||||
FAR struct mofile_s *mofile;
|
FAR struct mofile_s *mofile;
|
||||||
FAR const char *lang;
|
FAR const char *lang;
|
||||||
char path[PATH_MAX];
|
|
||||||
FAR char *notrans;
|
FAR char *notrans;
|
||||||
FAR char *trans;
|
FAR char *trans;
|
||||||
|
FAR char *path;
|
||||||
|
|
||||||
notrans = (FAR char *)(n == 1 ? msgid1 : msgid2);
|
notrans = (FAR char *)(n == 1 ? msgid1 : msgid2);
|
||||||
|
|
||||||
|
|
@ -576,6 +576,12 @@ FAR char *dcngettext(FAR const char *domainname,
|
||||||
lang = "C";
|
lang = "C";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
return notrans;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(path, PATH_MAX,
|
snprintf(path, PATH_MAX,
|
||||||
CONFIG_LIBC_LOCALE_PATH"/%s/%s/%s.mo",
|
CONFIG_LIBC_LOCALE_PATH"/%s/%s/%s.mo",
|
||||||
lang, g_catname[category], domainname);
|
lang, g_catname[category], domainname);
|
||||||
|
|
@ -598,6 +604,7 @@ FAR char *dcngettext(FAR const char *domainname,
|
||||||
if (mofile == NULL)
|
if (mofile == NULL)
|
||||||
{
|
{
|
||||||
nxmutex_unlock(&g_lock);
|
nxmutex_unlock(&g_lock);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return notrans;
|
return notrans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -606,6 +613,7 @@ FAR char *dcngettext(FAR const char *domainname,
|
||||||
if (mofile->map == MAP_FAILED)
|
if (mofile->map == MAP_FAILED)
|
||||||
{
|
{
|
||||||
nxmutex_unlock(&g_lock);
|
nxmutex_unlock(&g_lock);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
lib_free(mofile);
|
lib_free(mofile);
|
||||||
return notrans;
|
return notrans;
|
||||||
}
|
}
|
||||||
|
|
@ -651,6 +659,7 @@ FAR char *dcngettext(FAR const char *domainname,
|
||||||
}
|
}
|
||||||
|
|
||||||
nxmutex_unlock(&g_lock); /* Leave look before search */
|
nxmutex_unlock(&g_lock); /* Leave look before search */
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
|
|
||||||
trans = molookup(mofile->map, mofile->size, msgid1);
|
trans = molookup(mofile->map, mofile->size, msgid1);
|
||||||
if (trans == NULL)
|
if (trans == NULL)
|
||||||
|
|
|
||||||
|
|
@ -66,20 +66,33 @@
|
||||||
|
|
||||||
int fchmodat(int dirfd, FAR const char *path, mode_t mode, int flags)
|
int fchmodat(int dirfd, FAR const char *path, mode_t mode, int flags)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & AT_SYMLINK_NOFOLLOW) != 0)
|
if ((flags & AT_SYMLINK_NOFOLLOW) != 0)
|
||||||
{
|
{
|
||||||
return lchmod(fullpath, mode);
|
ret = lchmod(fullpath, mode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = chmod(fullpath, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return chmod(fullpath, mode);
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,20 +67,33 @@
|
||||||
int fstatat(int dirfd, FAR const char *path, FAR struct stat *buf,
|
int fstatat(int dirfd, FAR const char *path, FAR struct stat *buf,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & AT_SYMLINK_NOFOLLOW) != 0)
|
if ((flags & AT_SYMLINK_NOFOLLOW) != 0)
|
||||||
{
|
{
|
||||||
return lstat(fullpath, buf);
|
ret = lstat(fullpath, buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = stat(fullpath, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stat(fullpath, buf);
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
|
|
@ -60,9 +61,17 @@
|
||||||
|
|
||||||
key_t ftok(FAR const char *pathname, int proj_id)
|
key_t ftok(FAR const char *pathname, int proj_id)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX] = CONFIG_LIBC_FTOK_VFS_PATH "/";
|
FAR char *fullpath;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
return (key_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(fullpath, PATH_MAX, "%s/",
|
||||||
|
CONFIG_LIBC_FTOK_VFS_PATH);
|
||||||
strlcat(fullpath, pathname, sizeof(fullpath));
|
strlcat(fullpath, pathname, sizeof(fullpath));
|
||||||
if (stat(fullpath, &st) < 0 && get_errno() == ENOENT)
|
if (stat(fullpath, &st) < 0 && get_errno() == ENOENT)
|
||||||
{
|
{
|
||||||
|
|
@ -71,10 +80,12 @@ key_t ftok(FAR const char *pathname, int proj_id)
|
||||||
if (mkdir(fullpath, S_IRWXU) < 0 ||
|
if (mkdir(fullpath, S_IRWXU) < 0 ||
|
||||||
stat(fullpath, &st) < 0)
|
stat(fullpath, &st) < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
return (key_t)-1;
|
return (key_t)-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
return ((key_t)proj_id << 24 |
|
return ((key_t)proj_id << 24 |
|
||||||
(key_t)(st.st_dev & 0xff) << 16 |
|
(key_t)(st.st_dev & 0xff) << 16 |
|
||||||
(key_t)(st.st_ino & 0xffff));
|
(key_t)(st.st_ino & 0xffff));
|
||||||
|
|
|
||||||
|
|
@ -417,11 +417,17 @@ int glob(FAR const char *pat, int flags,
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t offs = (flags & GLOB_DOOFFS) ? g->gl_offs : 0;
|
size_t offs = (flags & GLOB_DOOFFS) ? g->gl_offs : 0;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
char buf[PATH_MAX];
|
FAR char *buf;
|
||||||
|
|
||||||
head.next = NULL;
|
head.next = NULL;
|
||||||
head.name[0] = '\0';
|
head.name[0] = '\0';
|
||||||
|
|
||||||
|
buf = lib_get_pathbuffer();
|
||||||
|
if (buf == NULL)
|
||||||
|
{
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
if (!errfunc)
|
if (!errfunc)
|
||||||
{
|
{
|
||||||
errfunc = ignore_err;
|
errfunc = ignore_err;
|
||||||
|
|
@ -442,6 +448,7 @@ int glob(FAR const char *pat, int flags,
|
||||||
|
|
||||||
if (!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(buf);
|
||||||
return GLOB_NOSPACE;
|
return GLOB_NOSPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -453,6 +460,7 @@ int glob(FAR const char *pat, int flags,
|
||||||
lib_free(p);
|
lib_free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lib_put_pathbuffer(buf);
|
||||||
if (error == GLOB_NOSPACE)
|
if (error == GLOB_NOSPACE)
|
||||||
{
|
{
|
||||||
freelist(&head);
|
freelist(&head);
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
#if defined(CONFIG_LIBC_MEMFD_TMPFS) || defined(CONFIG_LIBC_MEMFD_SHMFS)
|
#if defined(CONFIG_LIBC_MEMFD_TMPFS) || defined(CONFIG_LIBC_MEMFD_SHMFS)
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
@ -54,10 +55,17 @@ int memfd_create(FAR const char *name, unsigned int flags)
|
||||||
set_errno(ENOSYS);
|
set_errno(ENOSYS);
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
#else
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
snprintf(path, sizeof(path), LIBC_MEM_FD_VFS_PATH_FMT, name);
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(path, PATH_MAX, LIBC_MEM_FD_VFS_PATH_FMT, name);
|
||||||
# ifdef CONFIG_LIBC_MEMFD_SHMFS
|
# ifdef CONFIG_LIBC_MEMFD_SHMFS
|
||||||
ret = shm_open(path, O_RDWR | flags, 0660);
|
ret = shm_open(path, O_RDWR | flags, 0660);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
|
|
@ -73,6 +81,7 @@ int memfd_create(FAR const char *name, unsigned int flags)
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,15 +64,25 @@
|
||||||
|
|
||||||
int mkdirat(int dirfd, FAR const char *path, mode_t mode)
|
int mkdirat(int dirfd, FAR const char *path, mode_t mode)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mkdir(fullpath, mode);
|
ret = mkdir(fullpath, mode);
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,17 +114,27 @@ int mkfifo(FAR const char *pathname, mode_t mode)
|
||||||
|
|
||||||
int mkfifoat(int dirfd, FAR const char *path, mode_t mode)
|
int mkfifoat(int dirfd, FAR const char *path, mode_t mode)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mkfifo(fullpath, mode);
|
ret = mkfifo(fullpath, mode);
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_PIPES && CONFIG_DEV_FIFO_SIZE > 0 */
|
#endif /* CONFIG_PIPES && CONFIG_DEV_FIFO_SIZE > 0 */
|
||||||
|
|
|
||||||
|
|
@ -134,15 +134,25 @@ int mknod(FAR const char *path, mode_t mode, dev_t dev)
|
||||||
|
|
||||||
int mknodat(int dirfd, FAR const char *path, mode_t mode, dev_t dev)
|
int mknodat(int dirfd, FAR const char *path, mode_t mode, dev_t dev)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mknod(fullpath, mode, dev);
|
ret = mknod(fullpath, mode, dev);
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,13 +65,21 @@
|
||||||
|
|
||||||
int openat(int dirfd, FAR const char *path, int oflags, ...)
|
int openat(int dirfd, FAR const char *path, int oflags, ...)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
mode_t mode = 0;
|
mode_t mode = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
@ -85,5 +93,7 @@ int openat(int dirfd, FAR const char *path, int oflags, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
return open(fullpath, oflags, mode);
|
ret = open(fullpath, oflags, mode);
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,20 +66,33 @@
|
||||||
int utimensat(int dirfd, FAR const char *path,
|
int utimensat(int dirfd, FAR const char *path,
|
||||||
const struct timespec times[2], int flags)
|
const struct timespec times[2], int flags)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & AT_SYMLINK_NOFOLLOW) != 0)
|
if ((flags & AT_SYMLINK_NOFOLLOW) != 0)
|
||||||
{
|
{
|
||||||
return lutimens(fullpath, times);
|
ret = lutimens(fullpath, times);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = utimens(fullpath, times);
|
||||||
}
|
}
|
||||||
|
|
||||||
return utimens(fullpath, times);
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,23 +70,43 @@
|
||||||
int renameat(int olddirfd, FAR const char *oldpath,
|
int renameat(int olddirfd, FAR const char *oldpath,
|
||||||
int newdirfd, FAR const char *newpath)
|
int newdirfd, FAR const char *newpath)
|
||||||
{
|
{
|
||||||
char oldfullpath[PATH_MAX];
|
FAR char *oldfullpath;
|
||||||
char newfullpath[PATH_MAX];
|
FAR char *newfullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
oldfullpath = lib_get_pathbuffer();
|
||||||
|
if (oldfullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
newfullpath = lib_get_pathbuffer();
|
||||||
|
if (newfullpath == NULL)
|
||||||
|
{
|
||||||
|
lib_put_pathbuffer(oldfullpath);
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ret = lib_getfullpath(olddirfd, oldpath,
|
ret = lib_getfullpath(olddirfd, oldpath,
|
||||||
oldfullpath, sizeof(oldfullpath));
|
oldfullpath, PATH_MAX);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
ret = lib_getfullpath(newdirfd, newpath,
|
ret = lib_getfullpath(newdirfd, newpath,
|
||||||
newfullpath, sizeof(newfullpath));
|
newfullpath, PATH_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(oldfullpath);
|
||||||
|
lib_put_pathbuffer(newfullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rename(oldfullpath, newfullpath);
|
ret = rename(oldfullpath, newfullpath);
|
||||||
|
lib_put_pathbuffer(oldfullpath);
|
||||||
|
lib_put_pathbuffer(newfullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,15 +137,25 @@ int access(FAR const char *path, int amode)
|
||||||
|
|
||||||
int faccessat(int dirfd, FAR const char *path, int amode, int flags)
|
int faccessat(int dirfd, FAR const char *path, int amode, int flags)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return access(fullpath, amode);
|
ret = access(fullpath, amode);
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,11 @@
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <nuttx/lib/lib.h>
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_ENVIRON
|
#ifndef CONFIG_DISABLE_ENVIRON
|
||||||
|
|
||||||
|
|
@ -66,16 +68,26 @@
|
||||||
|
|
||||||
int fchdir(int fd)
|
int fchdir(int fd)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
FAR char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
path = lib_get_pathbuffer();
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ret = fcntl(fd, F_GETPATH, path);
|
ret = fcntl(fd, F_GETPATH, path);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return chdir(path);
|
ret = chdir(path);
|
||||||
|
lib_put_pathbuffer(path);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !CONFIG_DISABLE_ENVIRON */
|
#endif /* !CONFIG_DISABLE_ENVIRON */
|
||||||
|
|
|
||||||
|
|
@ -68,20 +68,33 @@
|
||||||
int fchownat(int dirfd, FAR const char *path, uid_t owner,
|
int fchownat(int dirfd, FAR const char *path, uid_t owner,
|
||||||
gid_t group, int flags)
|
gid_t group, int flags)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & AT_SYMLINK_NOFOLLOW) != 0)
|
if ((flags & AT_SYMLINK_NOFOLLOW) != 0)
|
||||||
{
|
{
|
||||||
return lchown(fullpath, owner, group);
|
ret = lchown(fullpath, owner, group);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = chown(fullpath, owner, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
return chown(fullpath, owner, group);
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,25 +78,45 @@
|
||||||
int linkat(int olddirfd, FAR const char *path1,
|
int linkat(int olddirfd, FAR const char *path1,
|
||||||
int newdirfd, FAR const char *path2, int flags)
|
int newdirfd, FAR const char *path2, int flags)
|
||||||
{
|
{
|
||||||
char oldfullpath[PATH_MAX];
|
FAR char *oldfullpath;
|
||||||
char newfullpath[PATH_MAX];
|
FAR char *newfullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
oldfullpath = lib_get_pathbuffer();
|
||||||
|
if (oldfullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
newfullpath = lib_get_pathbuffer();
|
||||||
|
if (newfullpath == NULL)
|
||||||
|
{
|
||||||
|
lib_put_pathbuffer(oldfullpath);
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ret = lib_getfullpath(olddirfd, path1,
|
ret = lib_getfullpath(olddirfd, path1,
|
||||||
oldfullpath, sizeof(oldfullpath));
|
oldfullpath, PATH_MAX);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
ret = lib_getfullpath(newdirfd, path2,
|
ret = lib_getfullpath(newdirfd, path2,
|
||||||
newfullpath, sizeof(newfullpath));
|
newfullpath, PATH_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(oldfullpath);
|
||||||
|
lib_put_pathbuffer(newfullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return link(oldfullpath, newfullpath);
|
ret = link(oldfullpath, newfullpath);
|
||||||
|
lib_put_pathbuffer(oldfullpath);
|
||||||
|
lib_put_pathbuffer(newfullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_PSEUDOFS_SOFTLINKS */
|
#endif /* CONFIG_PSEUDOFS_SOFTLINKS */
|
||||||
|
|
|
||||||
|
|
@ -70,17 +70,27 @@
|
||||||
ssize_t readlinkat(int dirfd, FAR const char *path, FAR char *buf,
|
ssize_t readlinkat(int dirfd, FAR const char *path, FAR char *buf,
|
||||||
size_t bufsize)
|
size_t bufsize)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return readlink(fullpath, buf, bufsize);
|
ret = readlink(fullpath, buf, bufsize);
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_PSEUDOFS_SOFTLINKS */
|
#endif /* CONFIG_PSEUDOFS_SOFTLINKS */
|
||||||
|
|
|
||||||
|
|
@ -67,17 +67,27 @@
|
||||||
|
|
||||||
int symlinkat(FAR const char *path1, int dirfd, FAR const char *path2)
|
int symlinkat(FAR const char *path1, int dirfd, FAR const char *path2)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path2, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path2, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return symlink(path1, fullpath);
|
ret = symlink(path1, fullpath);
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_PSEUDOFS_SOFTLINKS */
|
#endif /* CONFIG_PSEUDOFS_SOFTLINKS */
|
||||||
|
|
|
||||||
|
|
@ -68,20 +68,33 @@
|
||||||
|
|
||||||
int unlinkat(int dirfd, FAR const char *path, int flags)
|
int unlinkat(int dirfd, FAR const char *path, int flags)
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & AT_REMOVEDIR) != 0)
|
if ((flags & AT_REMOVEDIR) != 0)
|
||||||
{
|
{
|
||||||
return rmdir(fullpath);
|
ret = rmdir(fullpath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = unlink(fullpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return unlink(fullpath);
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,15 +53,25 @@ int utimes(FAR const char *path, const struct timeval tv[2])
|
||||||
|
|
||||||
int futimesat(int dirfd, FAR const char *path, const struct timeval tv[2])
|
int futimesat(int dirfd, FAR const char *path, const struct timeval tv[2])
|
||||||
{
|
{
|
||||||
char fullpath[PATH_MAX];
|
FAR char *fullpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
|
fullpath = lib_get_pathbuffer();
|
||||||
|
if (fullpath == NULL)
|
||||||
|
{
|
||||||
|
set_errno(ENOMEM);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
set_errno(-ret);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return utimes(fullpath, tv);
|
ret = utimes(fullpath, tv);
|
||||||
|
lib_put_pathbuffer(fullpath);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue