[Libsysio-commit] HEAD: libsysio/drivers/incore fs_incore.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2007-04-12 19:15:41
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25122/drivers/incore Modified Files: fs_incore.c Log Message: Too small a buffer passed would result in a premature EOF. Per Cray SPR #734717. The directory enumeration routine now tracks the number of valid copies it could have made. The filldirentries routine now checks that counter. If non-zero but no data was copied, it will return the proper "invalid argument" error. Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -w -b -B -p -r1.27 -r1.28 --- fs_incore.c 14 Mar 2007 19:14:33 -0000 1.27 +++ fs_incore.c 12 Apr 2007 19:15:37 -0000 1.28 @@ -954,20 +954,29 @@ incore_directory_position(struct intnl_d struct copy_info { void *data; size_t nbytes; + unsigned count; }; /* * Eumeration callback. * * Note: - * On those systems supporting white-out entries, they are returned. On - * systems without, they are not. + * Whiteout entries are never returned. */ static void * incore_directory_enumerate(struct intnl_dirent *de, size_t reclen, struct copy_info *cinfo) { +#ifdef DT_WHT + if (de->d_type == DT_WHT) { + /* + * Keep going but skip the copy. + */ + return NULL; + } +#endif + cinfo->count++; if (reclen > cinfo->nbytes) return de; (void *)memcpy(cinfo->data, de, reclen); @@ -1006,6 +1015,7 @@ _sysio_incore_dirop_filldirentries(struc copy_info.data = buf; copy_info.nbytes = nbytes; + copy_info.count = 0; off = (char *)de - (char *)icino->ici_data; de = incore_directory_probe(de, @@ -1014,10 +1024,14 @@ _sysio_incore_dirop_filldirentries(struc (probe_ty )incore_directory_enumerate, NULL, ©_info); - nbytes -= copy_info.nbytes; icino->ici_st.st_atime = time(NULL); + if (nbytes == copy_info.nbytes && copy_info.count) + return -EINVAL; + nbytes -= copy_info.nbytes; +#if 0 if (!nbytes) return -EOVERFLOW; +#endif *posp += nbytes; return (ssize_t )nbytes; } |