I'll keep this in mind
however, one of the other reasons for intercepting syscalls is to handle EINTR 
and retry

On Wed, 29 Aug 2012 06:54:05 +0200 =?KOI8-R?B?z8zYx8Egy9LZ1sHOz9fTy8HR?= wrote:
> Glenn, I have an alternative for your per thread open(), stat(),
> rename() and so on API plans:

> Instead of creating AST wrapper code for open(), stat(), rename() and
> so we could use the following macros, defined in <ast/fcntl.h>:

> ------------------cutme------------------------
> #define unlink(path)                  
> unlinkat(AST_GET_CURRENT_THREAD_CWD_FD(), (path), 0)
> #define rmdir(path)                   
> unlinkat(AST_GET_CURRENT_THREAD_CWD_FD(),
> (path), AT_REMOVEDIR)
> #define chown(path, uid,
> gid)          fchownat(AST_GET_CURRENT_THREAD_CWD_FD(), (path), (uid), (gid),
> 0)
> #define lchown(path, uid, gid)
>       fchownat(AST_GET_CURRENT_THREAD_CWD_FD(), (path), (uid), (gid),
> AT_SYMLINK_NOFOLLOW)
> #define stat(path, sb)                fstatat(AST_GET_CURRENT_THREAD_CWD_FD(),
> (path), (sb), 0)
> #define lstat(path, sb)               fstatat(AST_GET_CURRENT_THREAD_CWD_FD(),
> (path), (sb), AT_SYMLINK_NOFOLLOW)
> #define rename(oldname,
> newname)      renameat(AST_GET_CURRENT_THREAD_CWD_FD(), (oldname),
> AST_GET_CURRENT_THREAD_CWD_FD(), (newname))
> #define access(path,
> amode)                faccessat(AST_GET_CURRENT_THREAD_CWD_FD(), (path), 
> (amode), 0)
> #define eaccess(path,
> amode)                faccessat(AST_GET_CURRENT_THREAD_CWD_FD(), (path), 
> (amode),
> AT_EACCESS)
> #define mkdir(path, amode)            mkdirat(AST_GET_CURRENT_THREAD_CWD_FD(),
> (path), (amode))
> #define mkfifo(path, amode)           
> mkfifoat(AST_GET_CURRENT_THREAD_CWD_FD(),
> (path), (amode))
> #define mknod(path, amode,
> adev) mknodat(AST_GET_CURRENT_THREAD_CWD_FD(), (path), (amode),
> (adev))
> #define readlink(path, buf,
> bufsize)      readlinkat(AST_GET_CURRENT_THREAD_CWD_FD(), (path), (buf),
> (bufsize))
> #define symlink(oldpath, newpath)     symlinkat((oldpath),
> AST_GET_CURRENT_THREAD_CWD_FD(), (newpath))
> ------------------cutme------------------------

> AST_GET_CURRENT_THREAD_CWD_FD() would be defined to be a preprocessor
> macro, which will be a function returning the current thread's cwd fd;
> if there is none allocated for this thread yet it will be done by
> within that function, using open(".", O_search).

> However, consumers of the <ast/fcntl.h> header are _free_ to redefine
> this macro, for example src/cmd/ksh93/include/defs.h could define
> AST_GET_CURRENT_THREAD_CWD_FD() as
> #define AST_GET_CURRENT_THREAD_CWD_FD() (shp->pwdfd)
> This would, at least, save the function call overhead, and finally
> make use of (shp->pwdfd) as it was intended.

> What do you think? It would make things easier for you to implement,
> i.e. you only have to implement the per thread
> AST_GET_CURRENT_THREAD_CWD_FD(), and applications are free to use the
> *at() API if they wish to.

> Olga
> -- 
>       ,   _                                    _   ,
>      { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
> .----'-/`-/     olga.kryzhanov...@gmail.com   \-`\-'----.
>  `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
>       /\/\     Solaris/BSD//C/C++ programmer   /\/\
>       `--`                                      `--`

_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to