Ignore:
Timestamp:
May 27, 2009, 9:09:42 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/utils/net_status.c

    r133 r232  
    2020#include "utils/net.h"
    2121
    22 static int show_session(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
    23                         void *state)
    24 {
    25         bool *parseable = (bool *)state;
     22static int show_session(struct db_record *rec, void *private_data)
     23{
     24        bool *parseable = (bool *)private_data;
    2625        struct sessionid sessionid;
    2726
    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));
    3231
    3332        if (!process_exists(sessionid.pid)) {
     
    5251static int net_status_sessions(int argc, const char **argv)
    5352{
    54         TDB_CONTEXT *tdb;
     53        struct db_context *db;
    5554        bool parseable;
    5655
     
    7069        }
    7170
    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) {
    7674                d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb"));
    7775                return -1;
    7876        }
    7977
    80         tdb_traverse(tdb, show_session, &parseable);
    81         tdb_close(tdb);
     78        db->traverse_read(db, show_session, &parseable);
     79        TALLOC_FREE(db);
    8280
    8381        return 0;
     
    109107};
    110108
    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;
     109static int collect_pid(struct db_record *rec, void *private_data)
     110{
     111        struct sessionids *ids = (struct sessionids *)private_data;
    115112        struct sessionid sessionid;
    116113
    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));
    121118
    122119        if (!process_exists(sessionid.pid))
     
    172169{
    173170        struct sessionids ids;
    174         TDB_CONTEXT *tdb;
     171        struct db_context *db;
    175172
    176173        ids.num_entries = 0;
    177174        ids.entries = NULL;
    178175
    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) {
    183179                d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb"));
    184180                return -1;
    185181        }
    186182
    187         tdb_traverse(tdb, collect_pid, &ids);
    188         tdb_close(tdb);
     183        db->traverse_read(db, collect_pid, &ids);
     184        TALLOC_FREE(db);
    189185
    190186        connections_forall(show_share_parseable, &ids);
Note: See TracChangeset for help on using the changeset viewer.