Projects
Browse Source     Search     Timeline     Wiki

Changeset 23154

Show
Ignore:
Timestamp:
03/19/07 11:26:21 (21 months ago)
Author:
zarzycki@…
Message:

<rdar://problem/5071550> launchd needs exec on disk mount option

Location:
trunk/launchd/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/launchd/src/launchd.plist.5

    r23095 r23154  
    196196.It Sy QueueDirectories <array of strings> 
    197197Much like the WatchPaths option, this key will watch the paths for modifications. The difference being that the job will only be started if the path is a directory and the directory is not empty. 
     198.It Sy StartOnMount <boolean> 
     199This optional key causes the job to be started every time a filesystem is mounted. 
    198200.It Sy StartInterval <integer> 
    199201This optional key causes the job to be started every N seconds. 
  • trunk/launchd/src/launchd_core_logic.c

    r23151 r23154  
    223223static void jobmgr_log_stray_children(jobmgr_t jm); 
    224224static void jobmgr_remove(jobmgr_t jm); 
    225 static void jobmgr_dispatch_all(jobmgr_t jm); 
     225static void jobmgr_dispatch_all(jobmgr_t jm, bool newmounthack); 
    226226static job_t job_mig_intran2(jobmgr_t jm, mach_port_t p); 
    227227static void job_export_all2(jobmgr_t jm, launch_data_t where); 
     
    279279        unsigned int globargv:1, wait4debugger:1, unload_at_exit:1, stall_before_exec:1, only_once:1, 
    280280                     currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1, removal_pending:1, 
    281                      wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1; 
     281                     wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1; 
    282282        char label[0]; 
    283283}; 
     
    767767 
    768768        if (j->mgr->global_on_demand_cnt == 0) { 
    769                 jobmgr_dispatch_all(j->mgr); 
     769                jobmgr_dispatch_all(j->mgr, false); 
    770770        } 
    771771 
     
    10901090                if (strcasecmp(key, LAUNCH_JOBKEY_SESSIONCREATE) == 0) { 
    10911091                        j->session_create = value; 
     1092                } else if (strcasecmp(key, LAUNCH_JOBKEY_STARTONMOUNT) == 0) { 
     1093                        j->start_on_mount = value; 
    10921094                } 
    10931095                break; 
     
    17521754 
    17531755void 
    1754 jobmgr_dispatch_all(jobmgr_t jm) 
     1756jobmgr_dispatch_all(jobmgr_t jm, bool newmounthack) 
    17551757{ 
    17561758        jobmgr_t jmi, jmn; 
     
    17581760 
    17591761        SLIST_FOREACH_SAFE(jmi, &jm->submgrs, sle, jmn) { 
    1760                 jobmgr_dispatch_all(jmi); 
     1762                jobmgr_dispatch_all(jmi, newmounthack); 
    17611763        } 
    17621764 
    17631765        SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { 
    1764                 job_dispatch(ji, false); 
     1766                job_dispatch(ji, newmounthack ? ji->start_on_mount : false); 
    17651767        } 
    17661768} 
     
    19091911                        return (void)jobmgr_assumes(jm, false); 
    19101912                } 
     1913                break; 
     1914        case EVFILT_FS: 
     1915                if (kev->fflags & VQ_MOUNT) { 
     1916                        jobmgr_dispatch_all(jm, true); 
     1917                } 
     1918                jobmgr_dispatch_all_semaphores(jm); 
    19111919                break; 
    19121920        case EVFILT_TIMER: 
     
    35043512        if (!jm) { 
    35053513                jobmgr_assumes(jmr, kevent_mod(SIGTERM, EVFILT_SIGNAL, EV_ADD, 0, 0, jmr) != -1); 
     3514                jobmgr_assumes(jmr, kevent_mod(0, EVFILT_FS, EV_ADD|EV_CLEAR, VQ_MOUNT|VQ_UNMOUNT|VQ_UPDATE, 0, jmr) != -1); 
    35063515        } 
    35073516 
  • trunk/launchd/src/launchd_runtime.c

    r23124 r23154  
    4343#include <sys/mount.h> 
    4444#include <sys/reboot.h> 
     45#include <sys/fcntl.h> 
    4546#include <bsm/libbsm.h> 
    4647#include <malloc/malloc.h> 
     
    889890                record_caller_creds(&bufRequest->Head); 
    890891 
     892                /* 
     893                 * This is a total hack. We really need a bit in the kernel's proc 
     894                 * struct to declare our intent. 
     895                 */ 
     896                static int no_hang_fd = -1; 
     897                if (no_hang_fd == -1) { 
     898                        no_hang_fd = _fd(open("/dev/autofs_nowait", 0)); 
     899                } 
     900 
    891901                if (the_demux(&bufRequest->Head, &bufReply->Head) == FALSE) { 
    892902                        /* XXX - also gross */ 
  • trunk/launchd/src/liblaunch_public.h

    r23042 r23154  
    8282#define LAUNCH_JOBKEY_LOWPRIORITYIO             "LowPriorityIO" 
    8383#define LAUNCH_JOBKEY_SESSIONCREATE             "SessionCreate" 
     84#define LAUNCH_JOBKEY_STARTONMOUNT              "StartOnMount" 
    8485#define LAUNCH_JOBKEY_SOFTRESOURCELIMITS        "SoftResourceLimits" 
    8586#define LAUNCH_JOBKEY_HARDRESOURCELIMITS        "HardResourceLimits"