Subversion Repositories HelenOS

Rev

Rev 3643 | Rev 3650 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3643 Rev 3645
Line 103... Line 103...
103
    }
103
    }
104
 
104
 
105
    do {
105
    do {
106
        if (-1 == (bytes = read(fd1, buff, blen)))
106
        if (-1 == (bytes = read(fd1, buff, blen)))
107
            break;
107
            break;
-
 
108
        /* We read a terminating NULL */
-
 
109
        if (0 == bytes) {
-
 
110
            copied ++;
-
 
111
            break;
-
 
112
        }
108
        copied += bytes;
113
        copied += bytes;
109
        write(fd2, buff, blen);
114
        write(fd2, buff, blen);
110
    } while (bytes > 0);
115
    } while (bytes > 0);
111
 
116
 
112
    if (bytes == -1) {
117
    if (bytes == -1) {
Line 145... Line 150...
145
    return;
150
    return;
146
}
151
}
147
 
152
 
148
int cmd_cp(char **argv)
153
int cmd_cp(char **argv)
149
{
154
{
150
    unsigned int argc, buffer = CP_DEFAULT_BUFLEN, verbose = 0;
155
    unsigned int argc, buffer = 0, verbose = 0;
151
    int c, opt_ind;
156
    int c, opt_ind;
152
    int64_t ret;
157
    int64_t ret;
153
 
158
 
154
    argc = cli_count_args(argv);
159
    argc = cli_count_args(argv);
155
 
160
 
Line 174... Line 179...
174
                printf("%s: Invalid buffer specification, "
179
                printf("%s: Invalid buffer specification, "
175
                    "(should be a number greater than zero)\n",
180
                    "(should be a number greater than zero)\n",
176
                    cmdname);
181
                    cmdname);
177
                return CMD_FAILURE;
182
                return CMD_FAILURE;
178
            }
183
            }
-
 
184
            if (verbose)
-
 
185
                printf("Buffer = %d\n", buffer);
179
            break;
186
            break;
180
        }
187
        }
181
    }
188
    }
182
 
189
 
-
 
190
    if (buffer == 0)
-
 
191
        buffer = CP_DEFAULT_BUFLEN;
-
 
192
 
183
    argc -= optind;
193
    argc -= optind;
184
 
194
 
185
    if (argc != 2) {
195
    if (argc != 2) {
186
        printf("%s: invalid number of arguments. Try %s --help\n",
196
        printf("%s: invalid number of arguments. Try %s --help\n",
187
            cmdname, cmdname);
197
            cmdname, cmdname);
Line 189... Line 199...
189
    }
199
    }
190
 
200
 
191
    ret = copy_file(argv[optind], argv[optind + 1], buffer, verbose);
201
    ret = copy_file(argv[optind], argv[optind + 1], buffer, verbose);
192
 
202
 
193
    if (verbose)
203
    if (verbose)
194
        printf("%d bytes copied (buffer = %d)\n", ret, buffer);
204
        printf("%d bytes copied\n", ret);
195
 
205
 
196
    if (ret <= 0)
206
    if (ret <= 0)
197
        return CMD_SUCCESS;
207
        return CMD_SUCCESS;
198
    else
208
    else
199
        return CMD_FAILURE;
209
        return CMD_FAILURE;