Changeset 232 for branches/samba-3.2.x/source/utils/net_status.c
- Timestamp:
- May 27, 2009, 9:09:42 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/utils/net_status.c
r133 r232 20 20 #include "utils/net.h" 21 21 22 static int show_session(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, 23 void *state) 24 { 25 bool *parseable = (bool *)state; 22 static int show_session(struct db_record *rec, void *private_data) 23 { 24 bool *parseable = (bool *)private_data; 26 25 struct sessionid sessionid; 27 26 28 if ( dbuf.dsize != sizeof(sessionid))29 return 0; 30 31 memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));27 if (rec->value.dsize != sizeof(sessionid)) 28 return 0; 29 30 memcpy(&sessionid, rec->value.dptr, sizeof(sessionid)); 32 31 33 32 if (!process_exists(sessionid.pid)) { … … 52 51 static int net_status_sessions(int argc, const char **argv) 53 52 { 54 TDB_CONTEXT *tdb;53 struct db_context *db; 55 54 bool parseable; 56 55 … … 70 69 } 71 70 72 tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, 73 TDB_DEFAULT, O_RDONLY, 0); 74 75 if (tdb == NULL) { 71 db = db_open(NULL, lock_path("sessionid.tdb"), 0, 72 TDB_CLEAR_IF_FIRST, O_RDONLY, 0644); 73 if (db == NULL) { 76 74 d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb")); 77 75 return -1; 78 76 } 79 77 80 tdb_traverse(tdb, show_session, &parseable);81 tdb_close(tdb);78 db->traverse_read(db, show_session, &parseable); 79 TALLOC_FREE(db); 82 80 83 81 return 0; … … 109 107 }; 110 108 111 static int collect_pid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, 112 void *state) 113 { 114 struct sessionids *ids = (struct sessionids *)state; 109 static int collect_pid(struct db_record *rec, void *private_data) 110 { 111 struct sessionids *ids = (struct sessionids *)private_data; 115 112 struct sessionid sessionid; 116 113 117 if ( dbuf.dsize != sizeof(sessionid))118 return 0; 119 120 memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));114 if (rec->value.dsize != sizeof(sessionid)) 115 return 0; 116 117 memcpy(&sessionid, rec->value.dptr, sizeof(sessionid)); 121 118 122 119 if (!process_exists(sessionid.pid)) … … 172 169 { 173 170 struct sessionids ids; 174 TDB_CONTEXT *tdb;171 struct db_context *db; 175 172 176 173 ids.num_entries = 0; 177 174 ids.entries = NULL; 178 175 179 tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, 180 TDB_DEFAULT, O_RDONLY, 0); 181 182 if (tdb == NULL) { 176 db = db_open(NULL, lock_path("sessionid.tdb"), 0, 177 TDB_CLEAR_IF_FIRST, O_RDONLY, 0644); 178 if (db == NULL) { 183 179 d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb")); 184 180 return -1; 185 181 } 186 182 187 tdb_traverse(tdb, collect_pid, &ids);188 tdb_close(tdb);183 db->traverse_read(db, collect_pid, &ids); 184 TALLOC_FREE(db); 189 185 190 186 connections_forall(show_share_parseable, &ids);
Note:
See TracChangeset
for help on using the changeset viewer.