summaryrefslogtreecommitdiff
path: root/TODO
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2013-04-16 17:14:03 +0200
committerAndreas Baumann <abaumann@yahoo.com>2013-04-16 17:14:03 +0200
commit80208e2c59fc426e2dc2ea4c9af2fa7f064a3331 (patch)
tree1d867efe5635b9da67182ae3fc6bc96cecb82d2c /TODO
parent763274ef0019017b45969b4d4e827a13784edd14 (diff)
downloadpgfuse-80208e2c59fc426e2dc2ea4c9af2fa7f064a3331.tar.gz
pgfuse-80208e2c59fc426e2dc2ea4c9af2fa7f064a3331.tar.bz2
added some OIDs to path code for the blocks free operation
Diffstat (limited to 'TODO')
-rw-r--r--TODO80
1 files changed, 25 insertions, 55 deletions
diff --git a/TODO b/TODO
index 64409de..8a38be1 100644
--- a/TODO
+++ b/TODO
@@ -2,64 +2,34 @@ TODO list (in order of priority)
---------
- integrate statfs patch:
- - calculating the size:
- a) virtual things like real blocks and inodes
- b) select physical things in db:
- http://www.postgresql.org/docs/current/interactive/functions-admin.html#FUNCTIONS-ADMIN-DBSIZE
- - Can't do this, as the db user must be underprivileged:
- show data_directory;
- /var/lib/postgres/data
- ERROR: must be superuser to examine "data_directory"
- This is for objects in the default tablespace
- 1) get list of oids containing the data of the tables/indexes
- SELECT oid FROM pg_class WHERE relname = 'dir' AND relkind = 'r';
- select 'dir'::regclass::oid;
- 3) use default data dir or tablespace location to resolve the path
- SELECT reltablespace FROM pg_class WHERE relname = 'dir' AND relkind = 'r';
- => 0, means default tablespace of the database, so we have to ask
- the database:
- datname?
-
-
- select datname,dattablespace from pg_database;
- select spclocation from pg_tablespace where oid =
- >= 9.2
- select pg_tablespace_location('55025');
-
- other ways:
+
+The real df -k:
- explicit tablespace in create table:
- SELECT d.datname as "Name",
- r.rolname as "Owner",
- pg_catalog.pg_encoding_to_char(d.encoding) as "Encoding",
- pg_catalog.shobj_description(d.oid, 'pg_database') as "Description",
- t.spcname as "Tablespace"
-FROM pg_catalog.pg_database d
- JOIN pg_catalog.pg_roles r ON d.datdba = r.oid
- JOIN pg_catalog.pg_tablespace t on d.dattablespace = t.oid
-ORDER BY 1;
+#include <mntent.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/vfs.h>
+#include <unistd.h>
+int main(void) {
+ FILE* mtab = setmntent("/etc/mtab", "r");
+ struct mntent* m;
+ struct mntent mnt;
+ char strings[4096];
+ while ((m = getmntent_r(mtab, &mnt, strings, sizeof(strings)))) {
+ struct statfs fs;
+ if ((mnt.mnt_dir != NULL) && (statfs(mnt.mnt_dir, &fs) == 0)) {
+ unsigned long long int size = fs.f_blocks * fs.f_bsize;
+ unsigned long long int free = fs.f_bfree * fs.f_bsize;
+ unsigned long long int avail = fs.f_bavail * fs.f_bsize;
+ printf("%s %s size=%lld free=%lld avail=%lld\n",
+ mnt.mnt_fsname, mnt.mnt_dir, size, free, avail);
+ }
+ }
-
--- COALESCE(TS.spclocation, XS.spclocation, '') AS "location"
- SELECT N.nspname || '.' || C.relname AS "relation",
- CASE WHEN reltype = 0
- THEN pg_size_pretty(pg_total_relation_size(C.oid)) || ' (index)'
- ELSE pg_size_pretty(pg_total_relation_size(C.oid)) || ' (' || pg_size_pretty(pg_relation_size(C.oid)) || ' data)'
- END AS "size (data)",
- COALESCE(T.tablespace, I.tablespace, '') AS "tablespace"
-FROM pg_class C
-LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
-LEFT JOIN pg_tables T ON (T.tablename = C.relname)
-LEFT JOIN pg_indexes I ON (I.indexname = C.relname)
-LEFT JOIN pg_tablespace TS ON TS.spcname = T.tablespace
-LEFT JOIN pg_tablespace XS ON XS.spcname = I.tablespace
-WHERE nspname NOT IN ('pg_catalog','pg_toast','information_schema')
-ORDER BY pg_total_relation_size(C.oid) DESC;
-
-
-default case:
-$PGDATA/base
+ endmntent(mtab);
+}
- no Perl, Shell, Posix df dependency
- handling of most file system metadata