added QSE_XXX_EPERM to some files
This commit is contained in:
parent
5a642d0dd6
commit
662fdec270
@ -1185,8 +1185,8 @@ enum qse_awk_errnum_t
|
||||
QSE_AWK_ENOMEM, /**< insufficient memory */
|
||||
QSE_AWK_EINVAL, /**< invalid parameter or data */
|
||||
QSE_AWK_EACCES, /**< access denied */
|
||||
QSE_AWK_EPERM, /**< operation not permitted */
|
||||
QSE_AWK_ENOSUP, /**< not supported */
|
||||
QSE_AWK_ENOPER, /**< operation not allowed */
|
||||
QSE_AWK_ENOENT, /**< '${0}' not found */
|
||||
QSE_AWK_EEXIST, /**< '${0}' already exists */
|
||||
QSE_AWK_EIOERR, /**< I/O error */
|
||||
|
@ -57,8 +57,10 @@ enum qse_httpd_errnum_t
|
||||
QSE_HTTPD_ENOMEM,
|
||||
QSE_HTTPD_EINVAL,
|
||||
QSE_HTTPD_EACCES,
|
||||
QSE_HTTPD_EPERM,
|
||||
QSE_HTTPD_ENOENT,
|
||||
QSE_HTTPD_EEXIST,
|
||||
QSE_HTTPD_ENOTDIR,
|
||||
QSE_HTTPD_EINTR,
|
||||
QSE_HTTPD_EPIPE,
|
||||
QSE_HTTPD_EAGAIN,
|
||||
|
@ -47,8 +47,10 @@ enum qse_upxd_errnum_t
|
||||
QSE_UPXD_ENOMEM,
|
||||
QSE_UPXD_EINVAL,
|
||||
QSE_UPXD_EACCES,
|
||||
QSE_UPXD_EPERM,
|
||||
QSE_UPXD_ENOENT,
|
||||
QSE_UPXD_EEXIST,
|
||||
QSE_UPXD_ENOTDIR,
|
||||
QSE_UPXD_EINTR,
|
||||
QSE_UPXD_EAGAIN
|
||||
};
|
||||
|
@ -49,8 +49,10 @@ enum qse_dir_errnum_t
|
||||
QSE_DIR_ENOMEM, /**< out of memory */
|
||||
QSE_DIR_EINVAL, /**< invalid parameter */
|
||||
QSE_DIR_EACCES, /**< access denied */
|
||||
QSE_DIR_EPERM, /**< operation not permitted */
|
||||
QSE_DIR_ENOENT, /**< no such file */
|
||||
QSE_DIR_EEXIST, /**< already exist */
|
||||
QSE_DIR_ENOTDIR, /**< not a directory */
|
||||
QSE_DIR_EINTR, /**< interrupted */
|
||||
QSE_DIR_EPIPE, /**< broken pipe */
|
||||
QSE_DIR_EAGAIN /**< resource not available temporarily */
|
||||
|
@ -87,8 +87,10 @@ enum qse_fio_errnum_t
|
||||
QSE_FIO_ENOMEM, /**< out of memory */
|
||||
QSE_FIO_EINVAL, /**< invalid parameter */
|
||||
QSE_FIO_EACCES, /**< access denied */
|
||||
QSE_FIO_EPERM, /**< operation not permitted */
|
||||
QSE_FIO_ENOENT, /**< no such file */
|
||||
QSE_FIO_EEXIST, /**< already exist */
|
||||
QSE_FIO_ENOTDIR, /**< not a directory */
|
||||
QSE_FIO_EINTR, /**< interrupted */
|
||||
QSE_FIO_EPIPE, /**< broken pipe */
|
||||
QSE_FIO_EAGAIN /**< resource not available temporarily */
|
||||
|
@ -58,6 +58,7 @@ enum qse_fs_errnum_t
|
||||
QSE_FS_ENOMEM, /**< out of memory */
|
||||
QSE_FS_EINVAL, /**< invalid parameter */
|
||||
QSE_FS_EACCES, /**< access denied */
|
||||
QSE_FS_EPERM, /**< operation not permitted */
|
||||
QSE_FS_ENOENT, /**< no such file or directory */
|
||||
QSE_FS_EEXIST, /**< already exist */
|
||||
QSE_FS_EINTR, /**< interrupted */
|
||||
|
@ -40,20 +40,22 @@ typedef struct qse_mux_evt_t qse_mux_evt_t;
|
||||
|
||||
enum qse_mux_errnum_t
|
||||
{
|
||||
QSE_MUX_ENOERR = 0, /**< no error */
|
||||
QSE_MUX_EOTHER, /**< other error */
|
||||
QSE_MUX_ENOIMPL, /**< not implemented */
|
||||
QSE_MUX_ESYSERR, /**< subsystem(system call) error */
|
||||
QSE_MUX_EINTERN, /**< internal error */
|
||||
QSE_MUX_ENOERR = 0, /**< no error */
|
||||
QSE_MUX_EOTHER, /**< other error */
|
||||
QSE_MUX_ENOIMPL, /**< not implemented */
|
||||
QSE_MUX_ESYSERR, /**< subsystem(system call) error */
|
||||
QSE_MUX_EINTERN, /**< internal error */
|
||||
|
||||
QSE_MUX_ENOMEM, /**< out of memory */
|
||||
QSE_MUX_EINVAL, /**< invalid parameter */
|
||||
QSE_MUX_EACCES, /**< access denied */
|
||||
QSE_MUX_ENOENT, /**< no such file */
|
||||
QSE_MUX_EEXIST, /**< already exist */
|
||||
QSE_MUX_EINTR, /**< interrupted */
|
||||
QSE_MUX_EPIPE, /**< broken pipe */
|
||||
QSE_MUX_EAGAIN, /**< resource not available temporarily */
|
||||
QSE_MUX_ENOMEM, /**< out of memory */
|
||||
QSE_MUX_EINVAL, /**< invalid parameter */
|
||||
QSE_MUX_EACCES, /**< access denied */
|
||||
QSE_MUX_EPERM, /**< operation not permitted */
|
||||
QSE_MUX_ENOENT, /**< no such file */
|
||||
QSE_MUX_EEXIST, /**< already exist */
|
||||
QSE_MUX_ENOTDIR, /**< not a directory */
|
||||
QSE_MUX_EINTR, /**< interrupted */
|
||||
QSE_MUX_EPIPE, /**< broken pipe */
|
||||
QSE_MUX_EAGAIN, /**< resource not available temporarily */
|
||||
};
|
||||
typedef enum qse_mux_errnum_t qse_mux_errnum_t;
|
||||
|
||||
|
@ -68,8 +68,10 @@ enum qse_nwio_errnum_t
|
||||
QSE_NWIO_ENOMEM, /**< out of memory */
|
||||
QSE_NWIO_EINVAL, /**< invalid parameter */
|
||||
QSE_NWIO_EACCES, /**< access denied */
|
||||
QSE_NWIO_EPERM, /**< operation not permitted */
|
||||
QSE_NWIO_ENOENT, /**< no such file */
|
||||
QSE_NWIO_EEXIST, /**< already exist */
|
||||
QSE_NWIO_ENOTDIR, /**< not a directory */
|
||||
QSE_NWIO_EINTR, /**< interrupted */
|
||||
QSE_NWIO_ETMOUT, /**< timed out */
|
||||
QSE_NWIO_EPIPE, /**< broken pipe */
|
||||
|
@ -152,8 +152,10 @@ enum qse_pio_errnum_t
|
||||
QSE_PIO_ENOMEM, /**< out of memory */
|
||||
QSE_PIO_EINVAL, /**< invalid parameter */
|
||||
QSE_PIO_EACCES, /**< access denied */
|
||||
QSE_PIO_EPERM, /**< operation not permitted */
|
||||
QSE_PIO_ENOENT, /**< no such file */
|
||||
QSE_PIO_EEXIST, /**< already exist */
|
||||
QSE_PIO_ENOTDIR, /**< not a directory */
|
||||
QSE_PIO_EINTR, /**< interrupted */
|
||||
QSE_PIO_EPIPE, /**< broken pipe */
|
||||
QSE_PIO_EAGAIN, /**< resource not available temporarily */
|
||||
|
@ -79,8 +79,10 @@ enum qse_sio_errnum_t
|
||||
QSE_SIO_ENOMEM, /**< out of memory */
|
||||
QSE_SIO_EINVAL, /**< invalid parameter */
|
||||
QSE_SIO_EACCES, /**< access denied */
|
||||
QSE_SIO_EPERM, /**< operation not permitted */
|
||||
QSE_SIO_ENOENT, /**< no such file */
|
||||
QSE_SIO_EEXIST, /**< already exist */
|
||||
QSE_SIO_ENOTDIR, /**< not a directory */
|
||||
QSE_SIO_EINTR, /**< interrupted */
|
||||
QSE_SIO_EPIPE, /**< broken pipe */
|
||||
QSE_SIO_EAGAIN, /**< resource not available temporarily */
|
||||
|
@ -47,6 +47,7 @@ enum qse_tio_errnum_t
|
||||
QSE_TIO_ENOMEM, /**< out of memory */
|
||||
QSE_TIO_EINVAL, /**< invalid parameter */
|
||||
QSE_TIO_EACCES, /**< access denied */
|
||||
QSE_TIO_EPERM, /**< operation not permitted */
|
||||
QSE_TIO_ENOENT, /**< no such file */
|
||||
QSE_TIO_ENOSPC, /**< no more space */
|
||||
QSE_TIO_EILSEQ, /**< illegal sequence */
|
||||
|
@ -39,8 +39,8 @@ const qse_char_t* qse_awk_dflerrstr (const qse_awk_t* awk, qse_awk_errnum_t errn
|
||||
QSE_T("insufficient memory"),
|
||||
QSE_T("invalid parameter or data"),
|
||||
QSE_T("access denied"),
|
||||
QSE_T("not supported"),
|
||||
QSE_T("operation not allowed"),
|
||||
QSE_T("not supported"),
|
||||
QSE_T("'${0}' not found"),
|
||||
QSE_T("'${0}' already exists"),
|
||||
QSE_T("I/O error"),
|
||||
|
@ -57,6 +57,7 @@ enum
|
||||
DIR_ENOMEM,
|
||||
DIR_EINVAL,
|
||||
DIR_EACCES,
|
||||
DIR_EPERM,
|
||||
DIR_ENOENT,
|
||||
DIR_EMAPTOSCALAR
|
||||
};
|
||||
@ -98,6 +99,8 @@ static int dir_err_to_errnum (qse_dir_errnum_t num)
|
||||
return DIR_EINVAL;
|
||||
case QSE_DIR_EACCES:
|
||||
return DIR_EACCES;
|
||||
case QSE_DIR_EPERM:
|
||||
return DIR_EPERM;
|
||||
case QSE_DIR_ENOENT:
|
||||
return DIR_ENOENT;
|
||||
default:
|
||||
@ -117,6 +120,8 @@ static int awk_err_to_errnum (qse_awk_errnum_t num)
|
||||
return DIR_EINVAL;
|
||||
case QSE_AWK_EACCES:
|
||||
return DIR_EACCES;
|
||||
case QSE_AWK_EPERM:
|
||||
return DIR_EPERM;
|
||||
case QSE_AWK_ENOENT:
|
||||
return DIR_ENOENT;
|
||||
case QSE_AWK_EMAPTOSCALAR:
|
||||
@ -358,6 +363,7 @@ static qse_char_t* errmsg[] =
|
||||
QSE_T("insufficient memory"),
|
||||
QSE_T("invalid data"),
|
||||
QSE_T("access denied"),
|
||||
QSE_T("operation not permitted"),
|
||||
QSE_T("no entry"),
|
||||
QSE_T("cannot change a map to a scalar"),
|
||||
QSE_T("unknown error")
|
||||
|
@ -1857,7 +1857,7 @@ int qse_awk_addgbl (qse_awk_t* awk, const qse_char_t* name)
|
||||
if (awk->tree.ngbls > awk->tree.ngbls_base)
|
||||
{
|
||||
/* this function is not allowed after qse_awk_parse is called */
|
||||
SETERR_COD (awk, QSE_AWK_ENOPER);
|
||||
SETERR_COD (awk, QSE_AWK_EPERM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1884,7 +1884,7 @@ int qse_awk_delgbl (qse_awk_t* awk, const qse_char_t* name)
|
||||
if (awk->tree.ngbls > awk->tree.ngbls_base)
|
||||
{
|
||||
/* this function is not allow after qse_awk_parse is called */
|
||||
qse_awk_seterrnum (awk, QSE_AWK_ENOPER, QSE_NULL);
|
||||
qse_awk_seterrnum (awk, QSE_AWK_EPERM, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -816,7 +816,7 @@ qse_awk_rtx_t* qse_awk_rtx_open (
|
||||
awk->tree.chain_size == 0 &&
|
||||
qse_htb_getsize(awk->tree.funs) == 0)
|
||||
{
|
||||
qse_awk_seterrnum (awk, QSE_AWK_ENOPER, QSE_NULL);
|
||||
qse_awk_seterrnum (awk, QSE_AWK_EPERM, QSE_NULL);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
@ -1576,7 +1576,7 @@ qse_awk_val_t* qse_awk_rtx_callfun (
|
||||
{
|
||||
/* cannot call the function again when exit() is called
|
||||
* in an AWK program or qse_awk_rtx_stop() is invoked */
|
||||
SETERR_COD (rtx, QSE_AWK_ENOPER);
|
||||
SETERR_COD (rtx, QSE_AWK_EPERM);
|
||||
return QSE_NULL;
|
||||
}
|
||||
/*rtx->exit_level = EXIT_NONE;*/
|
||||
|
@ -140,7 +140,8 @@
|
||||
case EINVAL: return __SYSERRNUM__ (obj2, EINVAL); \
|
||||
case EBUSY: \
|
||||
case EACCES: return __SYSERRNUM__ (obj2, EACCES); \
|
||||
case ENOTDIR: \
|
||||
case EPERM: return __SYSERRNUM__ (obj2, EPERM); \
|
||||
case ENOTDIR: return __SYSERRNUM__ (obj2, ENOTDIR); \
|
||||
case ENOENT: return __SYSERRNUM__ (obj2, ENOENT); \
|
||||
case EEXIST: return __SYSERRNUM__ (obj2, EEXIST); \
|
||||
case EINTR: return __SYSERRNUM__ (obj2, EINTR); \
|
||||
@ -162,7 +163,8 @@
|
||||
case EINVAL: return __SYSERRNUM__ (obj2, EINVAL); \
|
||||
case EBUSY: \
|
||||
case EACCES: return __SYSERRNUM__ (obj2, EACCES); \
|
||||
case ENOTDIR: \
|
||||
case EPERM: return __SYSERRNUM__ (obj2, EPERM); \
|
||||
case ENOTDIR: return __SYSERRNUM__ (obj2, ENOTDIR); \
|
||||
case ENOENT: return __SYSERRNUM__ (obj2, ENOENT); \
|
||||
case EEXIST: return __SYSERRNUM__ (obj2, EEXIST); \
|
||||
case EINTR: return __SYSERRNUM__ (obj2, EINTR); \
|
||||
@ -183,7 +185,8 @@
|
||||
case EINVAL: return __SYSERRNUM__ (obj2, EINVAL); \
|
||||
case EBUSY: \
|
||||
case EACCES: return __SYSERRNUM__ (obj2, EACCES); \
|
||||
case ENOTDIR: \
|
||||
case EPERM: return __SYSERRNUM__ (obj2, EPERM); \
|
||||
case ENOTDIR: return __SYSERRNUM__ (obj2, ENOTDIR); \
|
||||
case ENOENT: return __SYSERRNUM__ (obj2, ENOENT); \
|
||||
case EEXIST: return __SYSERRNUM__ (obj2, EEXIST); \
|
||||
case EINTR: return __SYSERRNUM__ (obj2, EINTR); \
|
||||
@ -204,7 +207,8 @@
|
||||
case EINVAL: return __SYSERRNUM__ (obj2, EINVAL); \
|
||||
case EBUSY: \
|
||||
case EACCES: return __SYSERRNUM__ (obj2, EACCES); \
|
||||
case ENOTDIR: \
|
||||
case EPERM: return __SYSERRNUM__ (obj2, EPERM); \
|
||||
case ENOTDIR: return __SYSERRNUM__ (obj2, ENOTDIR); \
|
||||
case ENOENT: return __SYSERRNUM__ (obj2, ENOENT); \
|
||||
case EEXIST: return __SYSERRNUM__ (obj2, EEXIST); \
|
||||
case EINTR: return __SYSERRNUM__ (obj2, EINTR); \
|
||||
|
@ -396,6 +396,12 @@ static void pop_cfs (qse_fs_t* fs, cpfile_t* cpfile, qse_dir_t** dir)
|
||||
QSE_MMGR_FREE (fs->mmgr, cfs);
|
||||
}
|
||||
|
||||
static int can_copy_dir_into (qse_fs_t* fs, cpfile_t* cpfile)
|
||||
{
|
||||
/* TODO: */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int copy_file (qse_fs_t* fs, cpfile_t* cpfile)
|
||||
{
|
||||
#if defined(NO_RECURSION)
|
||||
@ -422,11 +428,12 @@ start_over:
|
||||
}
|
||||
|
||||
/* the destination is also a directory */
|
||||
|
||||
if (cpfile->src_attr.ino == cpfile->dst_attr.ino &&
|
||||
cpfile->src_attr.dev == cpfile->dst_attr.dev)
|
||||
{
|
||||
/* cannot copy a directory to itself */
|
||||
fs->errnum = QSE_FS_EINVAL; /* TODO: better error code */
|
||||
fs->errnum = QSE_FS_EPERM;
|
||||
goto oops;
|
||||
}
|
||||
|
||||
@ -462,12 +469,20 @@ start_over:
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* TODO: check if the directory is beging copied into itself in advance...XXXXXXXXXXXXXXXXXXXXXX */
|
||||
|
||||
if (qse_fs_mkdirsys (fs, cpfile->dst_fspath) <= -1)
|
||||
{
|
||||
/* it's ok if the destination directory already exists */
|
||||
if (fs->errnum != QSE_FS_EEXIST) goto oops;
|
||||
}
|
||||
|
||||
if (!can_copy_dir_into (fs, cpfile))
|
||||
{
|
||||
fs->errnum = QSE_FS_EPERM;
|
||||
goto oops;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
x = qse_dir_read (dir, &dirent);
|
||||
@ -533,29 +548,15 @@ start_over:
|
||||
cpfile->src_attr.dev == cpfile->dst_attr.dev)
|
||||
{
|
||||
/* cannot copy a file to itself */
|
||||
fs->errnum = QSE_FS_EINVAL; /* TODO: better error code */
|
||||
fs->errnum = QSE_FS_EPERM;
|
||||
goto oops;
|
||||
}
|
||||
|
||||
if (cpfile->dst_attr.isdir)
|
||||
{
|
||||
#if 0
|
||||
if (cpfile->flags & CPFILE_DST_FSPATH_MERGED)
|
||||
{
|
||||
/* merge_dstdir_and_file() has been called already.
|
||||
* no more getting into a subdirectory */
|
||||
fs->errnum = QSE_FS_EISDIR;
|
||||
goto oops;
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
/* arrange to copy a file into a directory */
|
||||
if (merge_dstdir_and_srcbase (fs, cpfile) <= -1) return -1;
|
||||
goto copy_file;
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
/* arrange to copy a file into a directory */
|
||||
if (merge_dstdir_and_srcbase (fs, cpfile) <= -1) return -1;
|
||||
goto copy_file;
|
||||
}
|
||||
|
||||
if (!(cpfile->flags & QSE_FS_CPFILE_REPLACE))
|
||||
@ -643,9 +644,10 @@ int qse_fs_cpfilembs (qse_fs_t* fs, const qse_mchar_t* srcpath, const qse_mchar_
|
||||
|
||||
if (flags & QSE_FS_CPFILE_GLOB)
|
||||
{
|
||||
fs->errnum = QSE_FS_ENOERR;
|
||||
if (qse_globmbs (srcpath, copy_file_for_glob, &ctx, DEFAULT_GLOB_FLAGS, fs->mmgr, fs->cmgr) <= -1)
|
||||
{
|
||||
fs->errnum = QSE_FS_EGLOB;
|
||||
if (fs->errnum == QSE_FS_ENOERR) fs->errnum = QSE_FS_EGLOB;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -672,9 +674,10 @@ int qse_fs_cpfilewcs (qse_fs_t* fs, const qse_wchar_t* srcpath, const qse_wchar_
|
||||
|
||||
if (flags & QSE_FS_CPFILE_GLOB)
|
||||
{
|
||||
fs->errnum = QSE_FS_ENOERR;
|
||||
if (qse_globwcs (srcpath, copy_file_for_glob, &ctx, DEFAULT_GLOB_FLAGS, fs->mmgr, fs->cmgr) <= -1)
|
||||
{
|
||||
fs->errnum = QSE_FS_EGLOB;
|
||||
if (fs->errnum == QSE_FS_ENOERR) fs->errnum = QSE_FS_EGLOB;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -108,9 +108,11 @@ qse_fs_errnum_t qse_fs_syserrtoerrnum (qse_fs_t* fs, qse_fs_syserr_t e)
|
||||
return QSE_FS_EINVAL;
|
||||
|
||||
case EACCES:
|
||||
case EPERM:
|
||||
return QSE_FS_EACCES;
|
||||
|
||||
case EPERM:
|
||||
return QSE_FS_EPERM;
|
||||
|
||||
case ENOENT:
|
||||
return QSE_FS_ENOENT;
|
||||
|
||||
@ -140,9 +142,11 @@ qse_fs_errnum_t qse_fs_syserrtoerrnum (qse_fs_t* fs, qse_fs_syserr_t e)
|
||||
return QSE_FS_EINVAL;
|
||||
|
||||
case EACCES:
|
||||
case EPERM:
|
||||
return QSE_FS_EACCES;
|
||||
|
||||
case EPERM:
|
||||
return QSE_FS_EPERM;
|
||||
|
||||
case ENOENT:
|
||||
return QSE_FS_ENOENT;
|
||||
|
||||
@ -199,6 +203,9 @@ qse_fs_errnum_t qse_fs_direrrtoerrnum (qse_fs_t* fs, qse_dir_errnum_t e)
|
||||
case QSE_DIR_EACCES:
|
||||
return QSE_FS_EACCES;
|
||||
|
||||
case QSE_DIR_EPERM:
|
||||
return QSE_FS_EPERM;
|
||||
|
||||
case QSE_DIR_ENOENT:
|
||||
return QSE_FS_ENOENT;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user