Re: svn commit: r1907984 - /httpd/httpd/trunk/modules/dav/fs/quota.c

2023-03-06 Thread Ruediger Pluem



On 3/2/23 4:46 PM, [email protected] wrote:
> Author: manu
> Date: Thu Mar  2 15:46:12 2023
> New Revision: 1907984
> 
> URL: http://svn.apache.org/viewvc?rev=1907984&view=rev
> Log:
> Add RFC4331 quotas for mod_dav_fs
> 
> Address forgotten svn add in previous commit
> 
> Added:
> httpd/httpd/trunk/modules/dav/fs/quota.c
> 
> Added: httpd/httpd/trunk/modules/dav/fs/quota.c
> URL: 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/fs/quota.c?rev=1907984&view=auto
> ==
> --- httpd/httpd/trunk/modules/dav/fs/quota.c (added)
> +++ httpd/httpd/trunk/modules/dav/fs/quota.c Thu Mar  2 15:46:12 2023
> @@ -0,0 +1,359 @@
> +/* Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +/*
> +** DAV filesystem-based quota routines
> +*/
> +
> +#include "apr.h"
> +#include "apr_strings.h"
> +
> +#include "httpd.h"
> +#include "http_log.h"
> +#include "http_main.h"
> +
> +#include "mod_dav.h"
> +#include "repos.h"
> +
> +/*
> + * Just use a configure test? fields have been standardized for
> + * while: https://pubs.opengroup.org/onlinepubs/7908799/xsh/sysstatvfs.h.html
> + */
> +#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(OpenBSD) || \
> +defined(linux)
> +#include 
> +#define HAVE_STATVFS
> +#endif
> +
> +#define DAV_TRUE1
> +#define DAV_FALSE   0
> +
> +/* Forwared declaration, since it calls itself */
> +static apr_status_t get_dir_used_bytes_walk(request_rec *r,
> +const char *path,
> +apr_off_t *used);
> +
> +static apr_status_t get_dir_used_bytes_walk(request_rec *r,
> +const char *path,
> +apr_off_t *used)
> +{
> +apr_dir_t *dir = NULL;
> +apr_finfo_t finfo;
> +apr_status_t rv;
> +
> +if ((rv = apr_dir_open(&dir, path, r->pool)) != APR_SUCCESS) {
> +ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
> +  "failed to open \"%s\"", path);
> +goto out;
> +}
> +
> +do {
> +apr_int32_t wanted;
> +char *newpath;
> +
> +wanted = 
> APR_FINFO_DIRENT|APR_FINFO_TYPE|APR_FINFO_SIZE|APR_FINFO_NAME;
> +rv = apr_dir_read(&finfo, wanted, dir);
> +if (rv != APR_SUCCESS && rv != APR_INCOMPLETE)
> +break;
> +
> +if (finfo.valid & APR_FINFO_NAME == 0) {
> +ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
> +  "Cannot get entry name in \"%s\"", path);
> +goto out;
> +}
> +
> +if (!strcmp(finfo.name, ".") ||
> +!strcmp(finfo.name, "..") ||
> +!strcmp(finfo.name, DAV_FS_STATE_DIR) ||
> +!strncmp(finfo.name, DAV_FS_TMP_PREFIX, 
> strlen(DAV_FS_TMP_PREFIX)))
> +continue;
> +
> +if (finfo.valid & APR_FINFO_TYPE == 0) {
> +ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
> +  "Cannot get entry type in \"%s\"", path);
> +goto out;
> +}
> +
> +switch (finfo.filetype) {
> +case APR_REG:
> +if (finfo.valid & APR_FINFO_SIZE == 0) {
> +ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
> +  "Cannot get entry size in \"%s\"", path);
> +goto out;
> +}
> +*used += finfo.size;
> +break;
> +
> +case APR_DIR:
> +if (finfo.valid & APR_FINFO_NAME == 0) {
> +ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
> +  "Cannot get entry name in \"%s\"", path);
> +goto out;
> +}

Why do we need to check this again? We already checked this above.

> +
> +rv = apr_filepath_merge(&newpath, path, finfo.name, 0, r->pool);
> +if (rv != APR_SUCCESS) {
> +ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
> +  "apr_filepath_merge \"%s\" \"%s\" failed",
> +  path, finfo.name);
> +goto out;
> +}
> +
> + 

Re: svn commit: r1907984 - /httpd/httpd/trunk/modules/dav/fs/quota.c

2023-03-02 Thread Yann Ylavic
Hi Emmanuel,

On Thu, Mar 2, 2023 at 4:46 PM  wrote:
>
> Author: manu
> Date: Thu Mar  2 15:46:12 2023
> New Revision: 1907984
>
> URL: http://svn.apache.org/viewvc?rev=1907984&view=rev
> Log:
> Add RFC4331 quotas for mod_dav_fs
>
> Address forgotten svn add in previous commit
>
> Added:
> httpd/httpd/trunk/modules/dav/fs/quota.c

Some warnings (errors with -Werror) raised by the ci:
https://github.com/apache/httpd/actions/runs/4315730441/jobs/7530520652#step:10:2809

Regards;
Yann.