From: Volker Lendecke Date: Mon, 26 Jan 2026 14:35:39 +0000 (+0100) Subject: lib: Convert sys_path_to_bdev to talloc X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96186f961721e94e588e9887cff8e90eefac742c;p=thirdparty%2Fsamba.git lib: Convert sys_path_to_bdev to talloc Next we'll have sys_dev_to_bdev based on string_list_make, which is talloc-based. Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/source3/lib/sysquotas.c b/source3/lib/sysquotas.c index e68be47f3c9..648d028c7d8 100644 --- a/source3/lib/sysquotas.c +++ b/source3/lib/sysquotas.c @@ -43,7 +43,11 @@ #endif /* NO_QUOTACTL_USED */ #if defined(HAVE_MNTENT) && defined(HAVE_REALPATH) -static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char **fs) +static int sys_path_to_bdev(TALLOC_CTX *mem_ctx, + const char *path, + char **mntpath, + char **bdev, + char **fs) { int ret = -1; SMB_STRUCT_STAT S; @@ -127,15 +131,15 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char continue ; if (S.st_ex_dev == devno) { - (*mntpath) = SMB_STRDUP(mnt->mnt_dir); - (*bdev) = SMB_STRDUP(mnt->mnt_fsname); - (*fs) = SMB_STRDUP(mnt->mnt_type); + (*mntpath) = talloc_strdup(mem_ctx, mnt->mnt_dir); + (*bdev) = talloc_strdup(mem_ctx, mnt->mnt_fsname); + (*fs) = talloc_strdup(mem_ctx, mnt->mnt_type); if ((*mntpath)&&(*bdev)&&(*fs)) { ret = 0; } else { - SAFE_FREE(*mntpath); - SAFE_FREE(*bdev); - SAFE_FREE(*fs); + TALLOC_FREE(*mntpath); + TALLOC_FREE(*bdev); + TALLOC_FREE(*fs); ret = -1; } @@ -153,7 +157,11 @@ out: #elif defined(HAVE_DEVNM) /* we have this on HPUX, ... */ -static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char **fs) +static int sys_path_to_bdev(TALLOC_CTX *mem_ctx, + const char *path, + char **mntpath, + char **bdev, + char **fs) { int ret = -1; char dev_disk[256]; @@ -180,13 +188,13 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char * but I don't know how * --metze */ - (*mntpath) = SMB_STRDUP(path); - (*bdev) = SMB_STRDUP(dev_disk); + (*mntpath) = talloc_strdup(mem_ctx, path); + (*bdev) = talloc_strdup(mem_dev_disk); if ((*mntpath)&&(*bdev)) { ret = 0; } else { - SAFE_FREE(*mntpath); - SAFE_FREE(*bdev); + TALLOC_FREE(*mntpath); + TALLOC_FREE(*bdev); ret = -1; } @@ -197,7 +205,11 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char /* #endif HAVE_DEVNM */ #else /* we should fake this up...*/ -static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char **fs) +static int sys_path_to_bdev(TALLOC_CTX *mem_ctx, + const char *path, + char **mntpath, + char **bdev, + char **fs) { int ret = -1; @@ -208,11 +220,11 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char (*bdev) = NULL; (*fs) = NULL; - (*mntpath) = SMB_STRDUP(path); + (*mntpath) = talloc_strdup(mem_ctx, path); if (*mntpath) { ret = 0; } else { - SAFE_FREE(*mntpath); + TALLOC_FREE(*mntpath); ret = -1; } @@ -431,7 +443,8 @@ int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DI return -1; } - if ((ret=sys_path_to_bdev(path,&mntpath,&bdev,&fs))!=0) { + ret = sys_path_to_bdev(talloc_tos(), path, &mntpath, &bdev, &fs); + if (ret != 0) { DEBUG(0,("sys_path_to_bdev() failed for path [%s]!\n",path)); return ret; } @@ -466,9 +479,9 @@ int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DI } } - SAFE_FREE(mntpath); - SAFE_FREE(bdev); - SAFE_FREE(fs); + TALLOC_FREE(mntpath); + TALLOC_FREE(bdev); + TALLOC_FREE(fs); return ret; } @@ -493,7 +506,8 @@ int sys_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DI return -1; } - if ((ret=sys_path_to_bdev(path,&mntpath,&bdev,&fs))!=0) { + ret = sys_path_to_bdev(talloc_tos(), path, &mntpath, &bdev, &fs); + if (ret != 0) { DEBUG(0,("sys_path_to_bdev() failed for path [%s]!\n",path)); return ret; } @@ -528,9 +542,9 @@ int sys_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DI } } - SAFE_FREE(mntpath); - SAFE_FREE(bdev); - SAFE_FREE(fs); + TALLOC_FREE(mntpath); + TALLOC_FREE(bdev); + TALLOC_FREE(fs); return ret; }