153 |
static RD_NTSTATUS NotifyInfo(RD_NTHANDLE handle, uint32 info_class, NOTIFY * p); |
static RD_NTSTATUS NotifyInfo(RD_NTHANDLE handle, uint32 info_class, NOTIFY * p); |
154 |
|
|
155 |
static time_t |
static time_t |
156 |
get_create_time(struct stat *st) |
get_create_time(struct stat *filestat) |
157 |
{ |
{ |
158 |
time_t ret, ret1; |
time_t ret, ret1; |
159 |
|
|
160 |
ret = MIN(st->st_ctime, st->st_mtime); |
ret = MIN(filestat->st_ctime, filestat->st_mtime); |
161 |
ret1 = MIN(ret, st->st_atime); |
ret1 = MIN(ret, filestat->st_atime); |
162 |
|
|
163 |
if (ret1 != (time_t) 0) |
if (ret1 != (time_t) 0) |
164 |
return ret1; |
return ret1; |
262 |
open_weak_exclusive(const char *pathname, int flags, mode_t mode) |
open_weak_exclusive(const char *pathname, int flags, mode_t mode) |
263 |
{ |
{ |
264 |
int ret; |
int ret; |
265 |
struct stat statbuf; |
struct stat filestat; |
266 |
|
|
267 |
ret = open(pathname, flags, mode); |
ret = open(pathname, flags, mode); |
268 |
if (ret != -1 || !(flags & O_EXCL)) |
if (ret != -1 || !(flags & O_EXCL)) |
291 |
} |
} |
292 |
|
|
293 |
/* Retry with GUARDED semantics */ |
/* Retry with GUARDED semantics */ |
294 |
if (stat(pathname, &statbuf) != -1) |
if (stat(pathname, &filestat) != -1) |
295 |
{ |
{ |
296 |
/* File exists */ |
/* File exists */ |
297 |
errno = EEXIST; |
errno = EEXIST; |
930 |
NotifyInfo(RD_NTHANDLE handle, uint32 info_class, NOTIFY * p) |
NotifyInfo(RD_NTHANDLE handle, uint32 info_class, NOTIFY * p) |
931 |
{ |
{ |
932 |
struct fileinfo *pfinfo; |
struct fileinfo *pfinfo; |
933 |
struct stat buf; |
struct stat filestat; |
934 |
struct dirent *dp; |
struct dirent *dp; |
935 |
char *fullname; |
char *fullname; |
936 |
DIR *dpr; |
DIR *dpr; |
937 |
|
|
938 |
pfinfo = &(g_fileinfo[handle]); |
pfinfo = &(g_fileinfo[handle]); |
939 |
if (fstat(handle, &buf) < 0) |
if (fstat(handle, &filestat) < 0) |
940 |
{ |
{ |
941 |
perror("NotifyInfo"); |
perror("NotifyInfo"); |
942 |
return RD_STATUS_ACCESS_DENIED; |
return RD_STATUS_ACCESS_DENIED; |
943 |
} |
} |
944 |
p->modify_time = buf.st_mtime; |
p->modify_time = filestat.st_mtime; |
945 |
p->status_time = buf.st_ctime; |
p->status_time = filestat.st_ctime; |
946 |
p->num_entries = 0; |
p->num_entries = 0; |
947 |
p->total_time = 0; |
p->total_time = 0; |
948 |
|
|
963 |
fullname = (char *) xmalloc(strlen(pfinfo->path) + strlen(dp->d_name) + 2); |
fullname = (char *) xmalloc(strlen(pfinfo->path) + strlen(dp->d_name) + 2); |
964 |
sprintf(fullname, "%s/%s", pfinfo->path, dp->d_name); |
sprintf(fullname, "%s/%s", pfinfo->path, dp->d_name); |
965 |
|
|
966 |
if (!stat(fullname, &buf)) |
if (!stat(fullname, &filestat)) |
967 |
{ |
{ |
968 |
p->total_time += (buf.st_mtime + buf.st_ctime); |
p->total_time += (filestat.st_mtime + filestat.st_ctime); |
969 |
} |
} |
970 |
|
|
971 |
xfree(fullname); |
xfree(fullname); |
1115 |
char *dirname, fullpath[PATH_MAX]; |
char *dirname, fullpath[PATH_MAX]; |
1116 |
DIR *pdir; |
DIR *pdir; |
1117 |
struct dirent *pdirent; |
struct dirent *pdirent; |
1118 |
struct stat fstat; |
struct stat filestat; |
1119 |
struct fileinfo *pfinfo; |
struct fileinfo *pfinfo; |
1120 |
|
|
1121 |
pfinfo = &(g_fileinfo[handle]); |
pfinfo = &(g_fileinfo[handle]); |
1145 |
/* Get information for directory entry */ |
/* Get information for directory entry */ |
1146 |
sprintf(fullpath, "%s/%s", dirname, pdirent->d_name); |
sprintf(fullpath, "%s/%s", dirname, pdirent->d_name); |
1147 |
|
|
1148 |
if (stat(fullpath, &fstat)) |
if (stat(fullpath, &filestat)) |
1149 |
{ |
{ |
1150 |
switch (errno) |
switch (errno) |
1151 |
{ |
{ |
1153 |
case ELOOP: |
case ELOOP: |
1154 |
case EACCES: |
case EACCES: |
1155 |
/* These are non-fatal errors. */ |
/* These are non-fatal errors. */ |
1156 |
memset(&fstat, 0, sizeof(fstat)); |
memset(&filestat, 0, sizeof(filestat)); |
1157 |
break; |
break; |
1158 |
default: |
default: |
1159 |
/* Fatal error. By returning STATUS_NO_SUCH_FILE, |
/* Fatal error. By returning STATUS_NO_SUCH_FILE, |
1164 |
} |
} |
1165 |
} |
} |
1166 |
|
|
1167 |
if (S_ISDIR(fstat.st_mode)) |
if (S_ISDIR(filestat.st_mode)) |
1168 |
file_attributes |= FILE_ATTRIBUTE_DIRECTORY; |
file_attributes |= FILE_ATTRIBUTE_DIRECTORY; |
1169 |
if (pdirent->d_name[0] == '.') |
if (pdirent->d_name[0] == '.') |
1170 |
file_attributes |= FILE_ATTRIBUTE_HIDDEN; |
file_attributes |= FILE_ATTRIBUTE_HIDDEN; |
1171 |
if (!file_attributes) |
if (!file_attributes) |
1172 |
file_attributes |= FILE_ATTRIBUTE_NORMAL; |
file_attributes |= FILE_ATTRIBUTE_NORMAL; |
1173 |
if (!(fstat.st_mode & S_IWUSR)) |
if (!(filestat.st_mode & S_IWUSR)) |
1174 |
file_attributes |= FILE_ATTRIBUTE_READONLY; |
file_attributes |= FILE_ATTRIBUTE_READONLY; |
1175 |
|
|
1176 |
/* Return requested information */ |
/* Return requested information */ |
1177 |
out_uint8s(out, 8); /* unknown zero */ |
out_uint8s(out, 8); /* unknown zero */ |
1178 |
|
|
1179 |
seconds_since_1970_to_filetime(get_create_time(&fstat), &ft_high, &ft_low); |
seconds_since_1970_to_filetime(get_create_time(&filestat), &ft_high, |
1180 |
|
&ft_low); |
1181 |
out_uint32_le(out, ft_low); /* create time */ |
out_uint32_le(out, ft_low); /* create time */ |
1182 |
out_uint32_le(out, ft_high); |
out_uint32_le(out, ft_high); |
1183 |
|
|
1184 |
seconds_since_1970_to_filetime(fstat.st_atime, &ft_high, &ft_low); |
seconds_since_1970_to_filetime(filestat.st_atime, &ft_high, &ft_low); |
1185 |
out_uint32_le(out, ft_low); /* last_access_time */ |
out_uint32_le(out, ft_low); /* last_access_time */ |
1186 |
out_uint32_le(out, ft_high); |
out_uint32_le(out, ft_high); |
1187 |
|
|
1188 |
seconds_since_1970_to_filetime(fstat.st_mtime, &ft_high, &ft_low); |
seconds_since_1970_to_filetime(filestat.st_mtime, &ft_high, &ft_low); |
1189 |
out_uint32_le(out, ft_low); /* last_write_time */ |
out_uint32_le(out, ft_low); /* last_write_time */ |
1190 |
out_uint32_le(out, ft_high); |
out_uint32_le(out, ft_high); |
1191 |
|
|
1192 |
seconds_since_1970_to_filetime(fstat.st_ctime, &ft_high, &ft_low); |
seconds_since_1970_to_filetime(filestat.st_ctime, &ft_high, &ft_low); |
1193 |
out_uint32_le(out, ft_low); /* change_write_time */ |
out_uint32_le(out, ft_low); /* change_write_time */ |
1194 |
out_uint32_le(out, ft_high); |
out_uint32_le(out, ft_high); |
1195 |
|
|
1196 |
out_uint32_le(out, fstat.st_size); /* filesize low */ |
out_uint32_le(out, filestat.st_size); /* filesize low */ |
1197 |
out_uint32_le(out, 0); /* filesize high */ |
out_uint32_le(out, 0); /* filesize high */ |
1198 |
out_uint32_le(out, fstat.st_size); /* filesize low */ |
out_uint32_le(out, filestat.st_size); /* filesize low */ |
1199 |
out_uint32_le(out, 0); /* filesize high */ |
out_uint32_le(out, 0); /* filesize high */ |
1200 |
out_uint32_le(out, file_attributes); |
out_uint32_le(out, file_attributes); |
1201 |
out_uint8(out, 2 * strlen(pdirent->d_name) + 2); /* unicode length */ |
out_uint8(out, 2 * strlen(pdirent->d_name) + 2); /* unicode length */ |