Quota-Backend-Cleanup/Logging
All checks were successful
Source release / source-package (push) Successful in 37s

This commit is contained in:
Mario Fetka
2026-05-25 23:16:31 +02:00
parent 3bf16d1e42
commit 1dc2c0a175
2 changed files with 100 additions and 18 deletions

View File

@@ -1298,7 +1298,7 @@ static time_t nw_2_un_time_parts(uint16 xdate, uint16 xtime)
#define DM_NCP22_25_SUPPORTED_BITS \
(DM_ATTRIBUTES | DM_CREATE_DATE | DM_CREATE_TIME | DM_CREATOR_ID | \
DM_NCP22_25_ARCHIVE_BITS | DM_NCP22_25_TIME_BITS | \
DM_INHERITED_RIGHTS_MASK)
DM_MODIFIER_ID | DM_INHERITED_RIGHTS_MASK | DM_MAXIMUM_SPACE)
static int set_ncp22_25_times(int volume, char *unixname, struct stat *stb,
NW_SET_DIR_INFO *f, uint32 change_mask,
@@ -1436,6 +1436,59 @@ static int set_ncp22_25_file_info(char *unixname,
return(result);
}
static int set_ncp22_25_maximum_space(int volume, char *unixname,
struct stat *stb,
NW_SET_DIR_INFO *f,
uint32 change_mask,
int is_dir)
{
uint32 max_space;
uint32 quota;
int result;
if (!(change_mask & DM_MAXIMUM_SPACE))
return(0);
/* NetWare exposes maximum space on directory entries. mars_nwe already
* has a Linux user-quota backend for volume restrictions; use that as the
* closest available mapping. Files have no max_space field in the DOS
* layout, so ignore the bit if a client sends it for a file.
*/
if (!is_dir) {
XDPRINTF((5,0,
"NCP22/25 maximum space ignored for file %s",
unixname ? unixname : ""));
return(0);
}
if (tru_eff_rights_exists(volume, unixname, stb, TRUSTEE_M))
return(-0x8c);
max_space = GET_BE32(f->u.d.max_space);
/* Treat the common unlimited sentinels as "remove restriction". */
if (max_space == MAX_U32 || max_space == 0x40000000UL)
quota = 0;
else
quota = max_space;
result = nw_set_vol_restrictions((uint8)volume, act_uid, quota);
if (result) {
/* If quota support is not compiled/enabled, do not break old clients. */
XDPRINTF((5,0,
"NCP22/25 maximum space quota ignored: vol=%d uid=%d max=0x%08lx rc=%d",
volume, act_uid, (unsigned long)max_space, result));
if (result == -0xfb)
return(0);
} else {
XDPRINTF((5,0,
"NCP22/25 maximum space quota set: vol=%d uid=%d max=0x%08lx quota=0x%08lx",
volume, act_uid, (unsigned long)max_space, (unsigned long)quota));
}
return(result);
}
static void log_ncp22_25_change_bits(uint32 change_mask)
{
uint32 unsupported = change_mask & ~DM_NCP22_25_SUPPORTED_BITS;
@@ -1448,9 +1501,8 @@ static void log_ncp22_25_change_bits(uint32 change_mask)
if (unsupported) {
XDPRINTF((5,0,
"NCP22/25 unsupported change bits ignored: maxspace=%d other=0x%08lx",
!!(change_mask & DM_MAXIMUM_SPACE),
(unsigned long)(unsupported & ~DM_MAXIMUM_SPACE)));
"NCP22/25 unsupported change bits ignored: other=0x%08lx",
(unsigned long)unsupported));
}
}
@@ -3101,7 +3153,15 @@ void get_dos_dir_attrib(NW_DOS_DIR_INFO *f,
}
un_date_2_nw(stb->st_mtime, f->modify_date, 0);
un_time_2_nw(stb->st_mtime, f->modify_time, 0);
U32_TO_BE32(MAX_U32, f->max_space);
{
uint32 quota = MAX_U32;
uint32 inuse = 0;
if (!nw_get_vol_restrictions((uint8)volume, act_uid, &quota, &inuse)) {
U32_TO_BE32(quota, f->max_space);
} else {
U32_TO_BE32(MAX_U32, f->max_space);
}
}
}
@@ -3215,6 +3275,10 @@ int nw_set_a_directory_entry(int dirhandle,
completition=set_ncp22_25_file_info(unixname, f, change_mask,
S_ISDIR(stbuff.st_mode));
}
if (!completition) {
completition=set_ncp22_25_maximum_space(nwpath.volume, unixname,
&stbuff, f, change_mask, S_ISDIR(stbuff.st_mode));
}
if (S_ISDIR(stbuff.st_mode)) {
if (change_mask & DM_INHERITED_RIGHTS_MASK) {
int result=tru_set_inherited_mask(nwpath.volume, unixname,