Handle volume restriction reads on volumes without quota backend
All checks were successful
Source release / source-package (push) Successful in 47s
All checks were successful
Source release / source-package (push) Successful in 47s
SYSCON reads volume/disk restrictions before opening the edit dialog. For volumes that do not map to a quota-capable block device, such as HOME on /home, the old code returned an error during the read path. This made SYSCON abort with error -30312 before the user could even see the restriction state. Treat read requests on volumes without a quota backend as unrestricted: return success with an unlimited quota and zero usage. Removing a restriction on such a volume is also treated as a successful no-op. Setting a non-zero restriction still fails, so admin tools do not report a quota as enforced when no Linux quota backend exists.
This commit is contained in:
@@ -982,7 +982,19 @@ int nw_set_vol_restrictions(uint8 volnr, int uid, uint32 quota)
|
||||
if (device == (char *) NULL) {
|
||||
XDPRINTF((2,0, "nw_set_vol_restrictions: no device for volume=%d path=%s",
|
||||
volnr, nw_volumes[volnr].unixname));
|
||||
return(-0x98);
|
||||
|
||||
/* A volume without a quota-capable backing device is effectively
|
||||
* unrestricted. Removing/unsetting a restriction is therefore a
|
||||
* successful no-op, but setting a real non-zero limit must fail so
|
||||
* admin tools do not report an enforced quota where no backend exists.
|
||||
*/
|
||||
if (quota == 0) {
|
||||
XDPRINTF((2,0,
|
||||
"nw_set_vol_restrictions: no quota device for volume=%d path=%s, remove/unlimited ignored",
|
||||
volnr, nw_volumes[volnr].unixname));
|
||||
return(0);
|
||||
}
|
||||
return(-0xfb);
|
||||
}
|
||||
|
||||
/* If this call fails then it it probable that quotas are not enabled
|
||||
@@ -1046,9 +1058,17 @@ int nw_get_vol_restrictions(uint8 volnr, int uid, uint32 *quota, uint32 *inuse)
|
||||
|
||||
device=find_device_file(nw_volumes[volnr].unixname);
|
||||
if (device == (char *) NULL) {
|
||||
XDPRINTF((2,0, "nw_get_vol_restrictions: no device for volume=%d path=%s",
|
||||
volnr, nw_volumes[volnr].unixname));
|
||||
return(-0x98);
|
||||
/* SYSCON reads restrictions before opening the edit dialog. Failing
|
||||
* this read on HOME-style or pseudo volumes makes it abort with -30312.
|
||||
* Report such volumes as unrestricted; actual non-zero Set/Change still
|
||||
* fails in nw_set_vol_restrictions().
|
||||
*/
|
||||
XDPRINTF((2,0,
|
||||
"nw_get_vol_restrictions: no quota device for volume=%d path=%s, returning unlimited",
|
||||
volnr, nw_volumes[volnr].unixname));
|
||||
*quota = 0x40000000;
|
||||
*inuse = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
XDPRINTF((2,0, "Get quota for uid %d on device %s",
|
||||
|
||||
Reference in New Issue
Block a user