linux (but not samba) quotas

Simo Sorce simo.sorce at polimi.it
Wed Mar 28 07:31:01 GMT 2001


This is a misconfiguration!
Why fixing misconfigurations in code?


On Tue, 27 Mar 2001, Jim McDonough wrote:

> Some time ago, someone presented an interesting situation...suppose the
> local fs quotas, but not samba quota support, are enabled.  When an NT
> client tries to write a file too large (say 1MB) to fit within the user's
> quota (say 4K remaining), the file size is set, then the file is written.
> An error is returned that the disk is full, but a (sort of) inconsistency
> arises: the file size appears to be 1MB, but only 4K worth of data is in
> the file.  Yeah yeah, sparse files and all that, but we've got folks
> complaining about that.  Since quota support isn't enabled, we can't detect
> that it won't fit, and we end up with this improper state.  I'd like to
> propose the following patch that checks to see if the file write failed due
> to quota limits and truncate the file at the current position.  I don't
> feel that this is the "right" thing to do, although there may not be a
> "right" answer.  Anyway, here's the code from 2.2:
>
> --- lib/util_sock.c Tue Mar 27 11:56:58 2001
> +++ ../../../mine/samba-2.2/source/lib/util_sock.c      Tue Mar 27 11:56:27
> 2001
> @@ -493,6 +493,7 @@
>  {
>    size_t total=0;
>    ssize_t ret;
> +  off_t off;
>
>    while (total < N)
>    {
> @@ -508,6 +509,10 @@
>
>      if (ret == -1) {
>        DEBUG(0,("write_data: write failure. Error = %s\n", strerror(errno)
> ));
> +      if (errno == EDQUOTA) {
> +        off = lseek(fd, 0, SEEK_CUR);
> +    ftruncate(fd, off);
> +      }
>        return -1;
>      }
>      if (ret == 0) return total;
>
>
> ----------------------------
> Jim McDonough
> Linux Technology Center
> IBM Boulder
>
> Notes: Jim McDonough/Boulder/IBM @ IBMUS
> VNET: JMCD at IBMUSM54
> Internet: jmcd at us.ibm.com
>
> Phone: (303) 924-5822
> T/L: 263-5822
>
>
>

-- 
Simo Sorce - Linux Systems Consultant
E-mail: simo.sorce at polimi.it
Tel: +39 0348 7149179 - Fax: +39 02 700442399
-----------------------------------------------------------------
Be happy, use Linux!





More information about the samba-technical mailing list