** dav_fs_load_locknull_list: Returns a dav_buffer dump of the locknull file ** for the given directory. */
| 743 | ** for the given directory. |
| 744 | */ |
| 745 | static dav_error * dav_fs_load_locknull_list(apr_pool_t *p, const char *dirpath, |
| 746 | dav_buffer *pbuf) |
| 747 | { |
| 748 | apr_finfo_t finfo; |
| 749 | apr_file_t *file = NULL; |
| 750 | dav_error *err = NULL; |
| 751 | apr_size_t amt; |
| 752 | apr_status_t rv; |
| 753 | |
| 754 | dav_buffer_init(p, pbuf, dirpath); |
| 755 | |
| 756 | if (pbuf->buf[pbuf->cur_len - 1] == '/') |
| 757 | pbuf->buf[--pbuf->cur_len] = '\0'; |
| 758 | |
| 759 | dav_buffer_place(p, pbuf, "/" DAV_FS_STATE_DIR "/" DAV_FS_LOCK_NULL_FILE); |
| 760 | |
| 761 | /* reset this in case we leave w/o reading into the buffer */ |
| 762 | pbuf->cur_len = 0; |
| 763 | |
| 764 | if (apr_file_open(&file, pbuf->buf, APR_READ | APR_BINARY, APR_OS_DEFAULT, |
| 765 | p) != APR_SUCCESS) { |
| 766 | return NULL; |
| 767 | } |
| 768 | |
| 769 | rv = apr_file_info_get(&finfo, APR_FINFO_SIZE, file); |
| 770 | if (rv != APR_SUCCESS) { |
| 771 | err = dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0, rv, |
| 772 | apr_psprintf(p, |
| 773 | "Opened but could not stat file %s", |
| 774 | pbuf->buf)); |
| 775 | goto loaderror; |
| 776 | } |
| 777 | |
| 778 | if (finfo.size != (apr_size_t)finfo.size) { |
| 779 | err = dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0, 0, |
| 780 | apr_psprintf(p, |
| 781 | "Opened but rejected huge file %s", |
| 782 | pbuf->buf)); |
| 783 | goto loaderror; |
| 784 | } |
| 785 | |
| 786 | amt = (apr_size_t)finfo.size; |
| 787 | dav_set_bufsize(p, pbuf, amt); |
| 788 | if ((rv = apr_file_read(file, pbuf->buf, &amt)) != APR_SUCCESS |
| 789 | || amt != finfo.size) { |
| 790 | err = dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0, rv, |
| 791 | apr_psprintf(p, |
| 792 | "Failure reading locknull file " |
| 793 | "for %s", dirpath)); |
| 794 | |
| 795 | /* just in case the caller disregards the returned error */ |
| 796 | pbuf->cur_len = 0; |
| 797 | goto loaderror; |
| 798 | } |
| 799 | |
| 800 | loaderror: |
| 801 | apr_file_close(file); |
| 802 | return err; |
no test coverage detected