Hi!
> >> This test case does not need to keep the file descriptors
> >> open after doing creat() on them. So we close them right after
> >> SAFE_CREAT.
> >>
> >> Otherwise on NFS it outputs:
> >>
> >> TWARN  :  tst_rmdir: rmobj(/tmpdir/ltp-vdIWJBmrkz/provfaUSg) failed: 
> >> remove(/tmpdir/ltp-vdIWJBmrkz/provfaUSg/tmp_root/hsym) failed; errno=66: 
> >> Directory not empty
> >>
> >> or:
> >> TWARN  :  tst_rmdir: rmobj(/mnt/proXZmq0T) failed: 
> >> unlink(/mnt/proXZmq0T/root/.nfs00000000000008470000015e) failed; errno=16: 
> >> Device or resource busy
> >>
> >> The same idea as for 8c200cb8e843724afb49fa6617fceec09ac826a5.
> >>
> >> Signed-off-by: Stanislav Kholmanskikh <[email protected]>
> >> ---
> >>   .../security/prot_hsymlinks/prot_hsymlinks.c       |    2 +-
> >>   1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c 
> >> b/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c
> >> index 558681a..4c05e3f 100644
> >> --- a/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c
> >> +++ b/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c
> >> @@ -414,7 +414,7 @@ static void ufiles_add(int usr, char *path, int type)
> >>    struct user_file *ufile = &users[usr].file[file];
> >>   
> >>    if (type == IS_FILE)
> >> -          SAFE_CREAT(cleanup, path, 0644);
> >> +          close(SAFE_CREAT(cleanup, path, 0644));
> >>    else
> >>            SAFE_MKDIR(cleanup, path, 0755);
> >>   
> > There is quite a lot of places in LTP where we do creat() and then
> > close(), what about adding SAFE_TOUCH() with touch(1) sematics to the
> > safe_file_ops.h in LTP lib?
> I'm ok with that, but I have two little questions:
> 
> 1. About the semantics.
> We use creat() with a 'mode' parameter. Should it just be passed to 
> open() (with O_CREAT) or should we explicitly call chmod(mode) after 
> open()/close()?
> In other words, should SAFE_TOUCH try to change the permissions if the 
> file exists?

I would go for changing the permissions if the file exists.

> At the moment I think about the following prototype:
> void safe_touch(const char *file, const int lineno,
>                            void (*cleanup_fn)(void),
>                            const char *pathname,
>                            mode_t mode, const struct timespec *times)

The timespec is used for specifying creation time?

> 2. Maybe move SAFE_TOUCH to safe_macros.h ?

I was thinking of safe_file_ops because safe_macros contains wrappers
around various libcalls and touch is not really libcall of any kind. But
that is minor.

-- 
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to