|
Packit |
8480eb |
/* ----------------------------------------------------------------------- *
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* state.h - state queue functions.
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* Copyright 2006 Ian Kent <raven@themaw.net>
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
8480eb |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
8480eb |
* the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
|
|
Packit |
8480eb |
* USA; either version 2 of the License, or (at your option) any later
|
|
Packit |
8480eb |
* version.
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
8480eb |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
8480eb |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
8480eb |
* GNU General Public License for more details.
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* ----------------------------------------------------------------------- */
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#ifndef STATE_H
|
|
Packit |
8480eb |
#define STATE_H
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#include <string.h>
|
|
Packit |
8480eb |
#include <stdlib.h>
|
|
Packit |
8480eb |
#include <signal.h>
|
|
Packit |
8480eb |
#include "automount.h"
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
/*
|
|
Packit |
8480eb |
* State machine for daemon
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* READY - reads from pipe; performs mount/umount operations
|
|
Packit |
8480eb |
* PRUNE - generates prune events in subprocess; reads from pipe
|
|
Packit |
8480eb |
* READMAP - read read map for maps taht use cache
|
|
Packit |
8480eb |
* EXPIRE - generates expire events in subprocess; reads from pipe
|
|
Packit |
8480eb |
* SHUTDOWN_PENDING - as prune, but goes to SHUTDOWN when done
|
|
Packit |
8480eb |
* SHUTDOWN - unmount autofs, exit
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
*/
|
|
Packit |
8480eb |
enum states {
|
|
Packit |
8480eb |
ST_ANY = -2,
|
|
Packit |
8480eb |
ST_INVAL,
|
|
Packit |
8480eb |
ST_INIT,
|
|
Packit |
8480eb |
ST_READY,
|
|
Packit |
8480eb |
ST_EXPIRE,
|
|
Packit |
8480eb |
ST_PRUNE,
|
|
Packit |
8480eb |
ST_READMAP,
|
|
Packit |
8480eb |
ST_SHUTDOWN_PENDING,
|
|
Packit |
8480eb |
ST_SHUTDOWN_FORCE,
|
|
Packit |
8480eb |
ST_SHUTDOWN
|
|
Packit |
8480eb |
};
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
struct expire_args {
|
|
Packit |
8480eb |
pthread_mutex_t mutex;
|
|
Packit |
8480eb |
pthread_cond_t cond;
|
|
Packit |
8480eb |
unsigned int signaled;
|
|
Packit |
8480eb |
struct autofs_point *ap; /* autofs mount we are working on */
|
|
Packit |
8480eb |
enum states state; /* State prune or expire */
|
|
Packit Service |
f51dba |
unsigned int how; /* Normal, immediate expire ? */
|
|
Packit |
8480eb |
int status; /* Return status */
|
|
Packit |
8480eb |
};
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define expire_args_mutex_lock(ea) \
|
|
Packit |
8480eb |
do { \
|
|
Packit |
8480eb |
int _ea_lock = pthread_mutex_lock(&ea->mutex); \
|
|
Packit |
8480eb |
if (_ea_lock) \
|
|
Packit |
8480eb |
fatal(_ea_lock); \
|
|
Packit |
8480eb |
} while (0)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define expire_args_mutex_unlock(ea) \
|
|
Packit |
8480eb |
do { \
|
|
Packit |
8480eb |
int _ea_unlock = pthread_mutex_unlock(&ea->mutex); \
|
|
Packit |
8480eb |
if (_ea_unlock) \
|
|
Packit |
8480eb |
fatal(_ea_unlock); \
|
|
Packit |
8480eb |
} while (0)
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
struct readmap_args {
|
|
Packit |
8480eb |
pthread_mutex_t mutex;
|
|
Packit |
8480eb |
pthread_cond_t cond;
|
|
Packit |
8480eb |
unsigned int signaled;
|
|
Packit |
8480eb |
struct autofs_point *ap; /* autofs mount we are working on */
|
|
Packit |
8480eb |
time_t now; /* Time when map is read */
|
|
Packit |
8480eb |
};
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
void st_mutex_lock(void);
|
|
Packit |
8480eb |
void st_mutex_unlock(void);
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
void expire_cleanup(void *);
|
|
Packit |
8480eb |
void expire_proc_cleanup(void *);
|
|
Packit |
8480eb |
void nextstate(int, enum states);
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
int st_add_task(struct autofs_point *, enum states);
|
|
Packit |
8480eb |
int __st_add_task(struct autofs_point *, enum states);
|
|
Packit |
8480eb |
void st_remove_tasks(struct autofs_point *);
|
|
Packit |
8480eb |
int st_wait_task(struct autofs_point *, enum states, unsigned int);
|
|
Packit |
8480eb |
int st_wait_state(struct autofs_point *ap, enum states state);
|
|
Packit |
8480eb |
int st_start_handler(void);
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#endif
|