--- IO-AIO/AIO.xs 2009/11/12 00:01:52 1.156 +++ IO-AIO/AIO.xs 2010/01/07 18:08:21 1.159 @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -142,6 +143,46 @@ # define POSIX_FADV_DONTNEED 0 #endif +#ifndef ST_NODEV +# define ST_NODEV 0 +#endif + +#ifndef ST_NOEXEC +# define ST_NOEXEC 0 +#endif + +#ifndef ST_SYNCHRONOUS +# define ST_SYNCHRONOUS 0 +#endif + +#ifndef ST_MANDLOCK +# define ST_MANDLOCK 0 +#endif + +#ifndef ST_WRITE +# define ST_WRITE 0 +#endif + +#ifndef ST_APPEND +# define ST_APPEND 0 +#endif + +#ifndef ST_IMMUTABLE +# define ST_IMMUTABLE 0 +#endif + +#ifndef ST_NOATIME +# define ST_NOATIME 0 +#endif + +#ifndef ST_NODIRATIME +# define ST_NODIRATIME 0 +#endif + +#ifndef ST_RELATIME +# define ST_RELATIME 0 +#endif + static int req_invoke (eio_req *req); #define EIO_FINISH(req) req_invoke (req) static void req_destroy (eio_req *grp); @@ -347,6 +388,36 @@ } break; + case EIO_STATVFS: + case EIO_FSTATVFS: + { + SV *rv = &PL_sv_undef; + + if (req->result >= 0) + { + EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); + HV *hv = newHV (); + + rv = sv_2mortal (newRV_noinc (hv)); + + hv_store (hv, "bsize" , sizeof ("bsize" ) - 1, newSVval64 (f->f_bsize ), 0); + hv_store (hv, "frsize" , sizeof ("frsize" ) - 1, newSVval64 (f->f_frsize ), 0); + hv_store (hv, "blocks" , sizeof ("blocks" ) - 1, newSVval64 (f->f_blocks ), 0); + hv_store (hv, "bfree" , sizeof ("bfree" ) - 1, newSVval64 (f->f_bfree ), 0); + hv_store (hv, "bavail" , sizeof ("bavail" ) - 1, newSVval64 (f->f_bavail ), 0); + hv_store (hv, "files" , sizeof ("files" ) - 1, newSVval64 (f->f_files ), 0); + hv_store (hv, "ffree" , sizeof ("ffree" ) - 1, newSVval64 (f->f_ffree ), 0); + hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); + hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); + hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); + hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); + } + + PUSHs (rv); + } + + break; + case EIO_GROUP: req->int1 = 2; /* mark group as finished */ @@ -547,6 +618,25 @@ const_iv (FADV_WILLNEED , POSIX_FADV_WILLNEED) const_iv (FADV_DONTNEED , POSIX_FADV_DONTNEED) + const_iv (ST_RDONLY , ST_RDONLY) + const_iv (ST_NOSUID , ST_NOSUID) + const_iv (ST_NODEV , ST_NODEV) + const_iv (ST_NOEXEC , ST_NOEXEC) + const_iv (ST_SYNCHRONOUS , ST_SYNCHRONOUS) + const_iv (ST_MANDLOCK , ST_MANDLOCK) + const_iv (ST_WRITE , ST_WRITE) + const_iv (ST_APPEND , ST_APPEND) + const_iv (ST_IMMUTABLE , ST_IMMUTABLE) + const_iv (ST_NOATIME , ST_NOATIME) + const_iv (ST_NODIRATIME , ST_NODIRATIME) + const_iv (ST_RELATIME , ST_RELATIME) + + const_eio (MS_ASYNC) + const_eio (MS_INVALIDATE) + const_eio (MS_SYNC) + + const_eio (MT_MODIFY) + const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) const_eio (SYNC_FILE_RANGE_WRITE) const_eio (SYNC_FILE_RANGE_WAIT_AFTER) @@ -809,8 +899,9 @@ void aio_stat (SV8 *fh_or_path, SV *callback=&PL_sv_undef) ALIAS: - aio_stat = EIO_STAT - aio_lstat = EIO_LSTAT + aio_stat = EIO_STAT + aio_lstat = EIO_LSTAT + aio_statvfs = EIO_STATVFS PPCODE: { dREQ; @@ -824,7 +915,7 @@ } else { - req->type = EIO_FSTAT; + req->type = ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT; req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); } @@ -997,6 +1088,40 @@ } void +aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) + ALIAS: + aio_mtouch = EIO_MTOUCH + aio_msync = EIO_MSYNC + PROTOTYPE: $$$$;$ + PPCODE: +{ + STRLEN svlen; + UV len = SvUV (length); + char *svptr = SvPVbyte (data, svlen); + + if (offset < 0) + offset += svlen; + + if (offset < 0 || offset > svlen) + croak ("offset outside of scalar"); + + if (!SvOK (length) || len + offset > svlen) + len = svlen - offset; + + { + dREQ; + + req->type = ix; + req->size = len; + req->sv2 = SvREFCNT_inc (data); + req->ptr2 = (char *)svptr + offset; + req->int1 = flags; + + REQ_SEND; + } +} + +void aio_busy (double delay, SV *callback=&PL_sv_undef) PPCODE: { @@ -1146,7 +1271,9 @@ sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) PROTOTYPE: $$$$ CODE: - eio_sendfile_sync (ofh, ifh, offset, count); + RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); + OUTPUT: + RETVAL void _on_next_submit (SV *cb) CODE: