* fhandler_disk_file.cc (fhandler_base::utimes_fs): Use existing handle if
fhandler has one. * times.cc (utimes): Scan open fds for matching paths and use existing fhandler if one exists.
This commit is contained in:
parent
b3982520d3
commit
5a90915d41
|
@ -1,3 +1,10 @@
|
||||||
|
2005-10-19 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
|
* fhandler_disk_file.cc (fhandler_base::utimes_fs): Use existing handle
|
||||||
|
if fhandler has one.
|
||||||
|
* times.cc (utimes): Scan open fds for matching paths and use existing
|
||||||
|
fhandler if one exists.
|
||||||
|
|
||||||
2005-10-19 Christopher Faylor <cgf@timesys.com>
|
2005-10-19 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
* pinfo.cc (_pinfo::dup_proc_pipe): Make warning more severe by
|
* pinfo.cc (_pinfo::dup_proc_pipe): Make warning more severe by
|
||||||
|
|
|
@ -865,7 +865,12 @@ fhandler_base::utimes_fs (const struct timeval *tvp)
|
||||||
{
|
{
|
||||||
FILETIME lastaccess, lastwrite;
|
FILETIME lastaccess, lastwrite;
|
||||||
struct timeval tmp[2];
|
struct timeval tmp[2];
|
||||||
|
bool closeit;
|
||||||
|
|
||||||
|
if (get_handle ())
|
||||||
|
closeit = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
query_open (query_write_attributes);
|
query_open (query_write_attributes);
|
||||||
if (!open_fs (O_BINARY, 0))
|
if (!open_fs (O_BINARY, 0))
|
||||||
{
|
{
|
||||||
|
@ -880,6 +885,8 @@ fhandler_base::utimes_fs (const struct timeval *tvp)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
closeit = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (nohandle ()) /* Directory query_open on 9x. */
|
if (nohandle ()) /* Directory query_open on 9x. */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -909,6 +916,7 @@ fhandler_base::utimes_fs (const struct timeval *tvp)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (closeit)
|
||||||
close ();
|
close ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ details. */
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "dtable.h"
|
#include "dtable.h"
|
||||||
|
#include "cygheap.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "hires.h"
|
#include "hires.h"
|
||||||
#include "cygtls.h"
|
#include "cygtls.h"
|
||||||
|
@ -445,8 +446,21 @@ extern "C" int
|
||||||
utimes (const char *path, const struct timeval *tvp)
|
utimes (const char *path, const struct timeval *tvp)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
fhandler_base *fh;
|
path_conv win32 (path, PC_SYM_FOLLOW);
|
||||||
|
fhandler_base *fh = NULL;
|
||||||
|
bool fromfd = false;
|
||||||
|
|
||||||
|
cygheap_fdenum cfd;
|
||||||
|
while (cfd.next () >= 0)
|
||||||
|
if (strcmp (cfd->get_win32_name (), win32) == 0)
|
||||||
|
{
|
||||||
|
fh = cfd;
|
||||||
|
fromfd = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fh)
|
||||||
|
{
|
||||||
if (!(fh = build_fh_name (path, NULL, PC_SYM_FOLLOW)))
|
if (!(fh = build_fh_name (path, NULL, PC_SYM_FOLLOW)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -455,10 +469,13 @@ utimes (const char *path, const struct timeval *tvp)
|
||||||
debug_printf ("got %d error from build_fh_name", fh->error ());
|
debug_printf ("got %d error from build_fh_name", fh->error ());
|
||||||
set_errno (fh->error ());
|
set_errno (fh->error ());
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
|
||||||
res = fh->utimes (tvp);
|
res = fh->utimes (tvp);
|
||||||
|
|
||||||
|
if (!fromfd)
|
||||||
delete fh;
|
delete fh;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
syscall_printf ("%d = utimes (%s, %p)", res, path, tvp);
|
syscall_printf ("%d = utimes (%s, %p)", res, path, tvp);
|
||||||
return res;
|
return res;
|
||||||
|
|
Loading…
Reference in New Issue