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

This commit is contained in:
Mario Fetka
2026-05-25 23:43:46 +02:00
parent b2c2ea96c6
commit f0aa83dea1

View File

@@ -888,40 +888,66 @@ int get_volume_user_trustee(int volume, uint32 id,
#include <mntent.h>
#include <errno.h>
/* Return the device special file that the specified path uses */
/* Return a quotactl() special argument for the filesystem used by path.
* Classic quota code wants the block device. Pseudo filesystems such as
* tmpfs do not have a block device in mnt_fsname; for them use the matching
* mount point. Linux quotactl() accepts this for tmpfs-style quota mounts.
*/
const char *find_device_file(const char *path)
{
struct stat s;
struct stat path_st;
struct stat mnt_st;
struct stat dev_st;
dev_t dev;
struct mntent *mntent;
FILE *fp;
static char mount_device[512];
static char mount_point[512];
int best_mount_len = -1;
mount_device[0] = '\0';
if (path == (char *) NULL || *path == '\0' || stat(path, &s) != 0)
mount_point[0] = '\0';
if (path == (char *) NULL || *path == '\0' || stat(path, &path_st) != 0)
return((char *) NULL);
dev = s.st_dev;
dev = path_st.st_dev;
if ((fp=setmntent(MOUNTED, "r")) == (FILE *) NULL)
return((char *) NULL);
while (!ferror(fp)) {
/* mntent will be a static struct mntent. Copy the device name before
* endmntent(), do not return a pointer into libc's mount table buffer.
*/
mntent = getmntent(fp);
if (mntent == (struct mntent *) NULL)
break;
if (stat(mntent->mnt_fsname, &s) == 0) {
if (S_ISCHR(s.st_mode) || S_ISBLK(s.st_mode)) {
if (s.st_rdev == dev) {
/* Found it */
strmaxcpy(mount_device, mntent->mnt_fsname, sizeof(mount_device)-1);
break;
}
if (stat(mntent->mnt_dir, &mnt_st) != 0 || mnt_st.st_dev != dev)
continue;
/* Remember the deepest matching mount point. */
if ((int)strlen(mntent->mnt_dir) > best_mount_len) {
best_mount_len = strlen(mntent->mnt_dir);
strmaxcpy(mount_point, mntent->mnt_dir, sizeof(mount_point)-1);
}
if (stat(mntent->mnt_fsname, &dev_st) == 0) {
if ((S_ISCHR(dev_st.st_mode) || S_ISBLK(dev_st.st_mode))
&& dev_st.st_rdev == dev) {
strmaxcpy(mount_device, mntent->mnt_fsname, sizeof(mount_device)-1);
break;
}
}
}
endmntent(fp);
return(mount_device[0] ? mount_device : (char *) NULL);
if (mount_device[0])
return(mount_device);
if (mount_point[0]) {
XDPRINTF((2,0, "find_device_file: using mount point %s for quota path %s",
mount_point, path));
return(mount_point);
}
return((char *) NULL);
}