~ubuntu-branches/ubuntu/natty/nilfs-tools/natty

« back to all changes in this revision

Viewing changes to sbin/mount/cleaner_ctl.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2010-05-03 21:19:37 UTC
  • mfrom: (1.2.1 upstream) (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100503211937-gopwb85vxi3606n2
Tags: 2.0.18-2
Dropping la files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * modify it under the terms of the GNU General Public
8
8
 * License as published by the Free Software Foundation; either
9
9
 * version 2 of the License, or (at your option) any later version.
10
 
 * 
 
10
 *
11
11
 * This program is distributed in the hope that it will be useful,
12
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
14
 * General Public License for more details.
15
 
 * 
 
15
 *
16
16
 * You should have received a copy of the GNU General Public
17
17
 * License along with this program; if not, write to the
18
18
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
45
45
 
46
46
const char cleanerd[] = "/sbin/" CLEANERD_NAME;
47
47
const char cleanerd_nofork_opt[] = "-n";
 
48
const char cleanerd_protperiod_opt[] = "-p";
48
49
 
49
50
extern char *progname;
50
51
 
54
55
        return (kill(pid, 0) == 0);
55
56
}
56
57
 
57
 
int start_cleanerd(const char *device, const char *mntdir, pid_t *ppid)
 
58
int start_cleanerd(const char *device, const char *mntdir,
 
59
                   unsigned long protperiod, pid_t *ppid)
58
60
{
59
 
        const char *dargs[5];
 
61
        const char *dargs[7];
60
62
        struct stat statbuf;
61
63
        int i = 0;
62
64
        int res;
 
65
        char buf[256];
63
66
 
64
67
        if (stat(cleanerd, &statbuf) != 0) {
65
68
                error(_("Warning: %s not found"), CLEANERD_NAME);
80
83
                }
81
84
                dargs[i++] = cleanerd;
82
85
                dargs[i++] = cleanerd_nofork_opt;
 
86
                if (protperiod != ULONG_MAX) {
 
87
                        dargs[i++] = cleanerd_protperiod_opt;
 
88
                        snprintf(buf, sizeof(buf), "%lu", protperiod);
 
89
                        dargs[i++] = buf;
 
90
                }
83
91
                dargs[i++] = device;
84
92
                dargs[i++] = mntdir;
85
93
                dargs[i] = NULL;
137
145
        int res;
138
146
 
139
147
        if (verbose)
140
 
                printf(_("%s: kill cleanerd (pid=%ld) on %s\n"), 
 
148
                printf(_("%s: kill cleanerd (pid=%ld) on %s\n"),
141
149
                       progname, (long)pid, spec);
142
150
 
143
151
        if (kill(pid, SIGTERM) < 0) {
153
161
                if (res < 0)
154
162
                        error("%s: wait timeout", progname);
155
163
                else
156
 
                        printf(_("%s: cleanerd (pid=%ld) stopped\n"), 
 
164
                        printf(_("%s: cleanerd (pid=%ld) stopped\n"),
157
165
                               progname, (long)pid);
158
166
        }
159
167
        return res;