MCPcopy Create free account
hub / github.com/apache/httpd / dav_fs_save_locknull_list

Function dav_fs_save_locknull_list

modules/dav/fs/lock.c:809–859  ·  view source on GitHub ↗

** dav_fs_save_locknull_list: Saves contents of pbuf into the ** locknull file for dirpath. */

Source from the content-addressed store, hash-verified

807** locknull file for dirpath.
808*/
809static dav_error * dav_fs_save_locknull_list(apr_pool_t *p, const char *dirpath,
810 dav_buffer *pbuf)
811{
812 const char *pathname;
813 apr_file_t *file = NULL;
814 dav_error *err = NULL;
815 apr_size_t amt;
816 apr_status_t rv;
817
818 if (pbuf->buf == NULL)
819 return NULL;
820
821 dav_fs_ensure_state_dir(p, dirpath);
822 pathname = apr_pstrcat(p,
823 dirpath,
824 dirpath[strlen(dirpath) - 1] == '/' ? "" : "/",
825 DAV_FS_STATE_DIR "/" DAV_FS_LOCK_NULL_FILE,
826 NULL);
827
828 if (pbuf->cur_len == 0) {
829 /* delete the file if cur_len == 0 */
830 if ((rv = apr_file_remove(pathname, p)) != APR_SUCCESS) {
831 return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0, rv,
832 apr_psprintf(p,
833 "Error removing %s", pathname));
834 }
835 return NULL;
836 }
837
838 if ((rv = apr_file_open(&file, pathname,
839 APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BINARY,
840 APR_OS_DEFAULT, p)) != APR_SUCCESS) {
841 return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0, rv,
842 apr_psprintf(p,
843 "Error opening %s for writing",
844 pathname));
845 }
846
847 amt = pbuf->cur_len;
848 if ((rv = apr_file_write_full(file, pbuf->buf, amt, &amt)) != APR_SUCCESS
849 || amt != pbuf->cur_len) {
850 err = dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0, rv,
851 apr_psprintf(p,
852 "Error writing %" APR_SIZE_T_FMT
853 " bytes to %s",
854 pbuf->cur_len, pathname));
855 }
856
857 apr_file_close(file);
858 return err;
859}
860
861/*
862** dav_fs_remove_locknull_member: Removes filename from the locknull list

Callers 2

Calls 2

dav_fs_ensure_state_dirFunction · 0.85
dav_new_errorFunction · 0.85

Tested by

no test coverage detected