starts with a drive.
Also perform whitespace cleanup.
+2004-05-28 Pierre Humblet <Pierre.Humblet@ieee.org>
+
+ * path.cc (chdir): Always use the normalized_path as posix_cwd, except
+ if it starts with a drive.
+
2004-05-25 Christopher Faylor <cgf@alum.bu.edu>
* winbase.h: Semi-revert previous patch as it caused strange behavior.
{
asm ("cpuid"
: "=a" (*a),
- "=b" (*b),
- "=c" (*c),
- "=d" (*d)
+ "=b" (*b),
+ "=c" (*c),
+ "=d" (*d)
: "a" (in));
}
}
bool has_impersonation_tokens ()
{ return external_token != INVALID_HANDLE_VALUE
- || internal_token != INVALID_HANDLE_VALUE
+ || internal_token != INVALID_HANDLE_VALUE
|| current_token != INVALID_HANDLE_VALUE; }
void close_impersonation_tokens ()
{
proc ipcblk;
union
{
- struct msgctl_args ctlargs;
+ struct msgctl_args ctlargs;
struct msgget_args getargs;
struct msgrcv_args rcvargs;
struct msgsnd_args sndargs;
proc ipcblk;
union
{
- struct semctl_args ctlargs;
+ struct semctl_args ctlargs;
struct semget_args getargs;
struct semop_args opargs;
};
UPTR is a pointer to global data that lives on the libc side of the
line [if one distinguishes the application from the dll]. */
-
+
extern "C" void __stdcall
_dll_crt0 ()
{
(DWORD) real_dir & ~FILE_ATTRIBUTE_READONLY);
for (bool is_cwd = false; ; is_cwd = true)
- {
+ {
DWORD err;
int rc = RemoveDirectory (real_dir);
DWORD att = GetFileAttributes (real_dir);
/* RemoveDirectory on a samba drive doesn't return an error if the
directory can't be removed because it's not empty. Checking for
existence afterwards keeps us informed about success. */
- if (att == INVALID_FILE_ATTRIBUTES)
- {
+ if (att == INVALID_FILE_ATTRIBUTES)
+ {
res = 0;
break;
}
SetCurrentDirectory. */
if (strcasematch (real_dir, cygheap->cwd.win32)
- && !strcasematch ("c:\\", cygheap->cwd.win32)
+ && !strcasematch ("c:\\", cygheap->cwd.win32)
&& !is_cwd
&& SetCurrentDirectory ("c:\\"))
continue;
-
- /* On 9X ERROR_ACCESS_DENIED is returned
+
+ /* On 9X ERROR_ACCESS_DENIED is returned
if you try to remove a non-empty directory. */
if (err == ERROR_ACCESS_DENIED
&& wincap.access_denied_on_delete ())
err = ERROR_DIR_NOT_EMPTY;
-
+
__seterrno_from_win_error (err);
-
+
/* Directory still exists, restore its characteristics. */
if (real_dir.has_attribute (FILE_ATTRIBUTE_READONLY))
SetFileAttributes (real_dir, real_dir);
if (cygheap->user.issetuid ())
for (unsigned i = 0; i < SPENVS_SIZE; i++)
if (!saw_spenv[i])
- {
+ {
*dstp = spenvs[i].retrieve (no_envblock);
if (*dstp && !no_envblock && *dstp != env_dontadd)
{
dstp++;
}
}
-
+
envc = dstp - newenv; /* Number of entries in newenv */
assert ((size_t) envc <= (n + SPENVS_SIZE));
*dstp = NULL; /* Terminate */
if (myself->ctty != -1)
{
if (type == CTRL_CLOSE_EVENT)
- {
+ {
sig_send (NULL, SIGHUP);
saw_close = true;
return FALSE;
}
if (!saw_close && type == CTRL_LOGOFF_EVENT)
- {
+ {
/* Check if the process is actually associated with a visible
window station, one which actually represents a visible desktop.
If not, the CTRL_LOGOFF_EVENT doesn't concern this process. */
return check_ntsec (filename);
}
case CW_GET_ERRNO_FROM_WINERROR:
- {
+ {
int error = va_arg (arg, int);
int deferrno = va_arg (arg, int);
return geterrno_from_win_error (error, deferrno);
memcpy (sd_buf, sd, sd.size ());
psa->lpSecurityDescriptor = sd_buf;
return 0;
- }
+ }
case CW_GET_SHMLBA:
- {
+ {
return getshmlba ();
}
case CW_GET_UID_FROM_SID:
- {
+ {
PSID psid = va_arg (arg, PSID);
cygsid sid (psid);
struct passwd *pw = internal_getpwsid (sid);
return pw ? pw->pw_uid : (__uid32_t)-1;
}
case CW_GET_GID_FROM_SID:
- {
+ {
PSID psid = va_arg (arg, PSID);
cygsid sid (psid);
struct __group32 *gr = internal_getgrsid (sid);
switch (query_open ())
{
case query_read_control:
- access = READ_CONTROL;
- create_options = FILE_OPEN_FOR_BACKUP_INTENT;
- break;
+ access = READ_CONTROL;
+ create_options = FILE_OPEN_FOR_BACKUP_INTENT;
+ break;
case query_stat_control:
- access = READ_CONTROL | FILE_READ_ATTRIBUTES;
- create_options = FILE_OPEN_FOR_BACKUP_INTENT;
- break;
+ access = READ_CONTROL | FILE_READ_ATTRIBUTES;
+ create_options = FILE_OPEN_FOR_BACKUP_INTENT;
+ break;
case query_write_control:
- access = READ_CONTROL | WRITE_OWNER | WRITE_DAC;
- create_options = FILE_OPEN_FOR_BACKUP_INTENT | FILE_OPEN_FOR_RECOVERY;
- break;
+ access = READ_CONTROL | WRITE_OWNER | WRITE_DAC;
+ create_options = FILE_OPEN_FOR_BACKUP_INTENT | FILE_OPEN_FOR_RECOVERY;
+ break;
default:
- create_options = 0;
+ create_options = 0;
if (get_major () == DEV_TAPE_MAJOR && (flags & O_TEXT))
{
/* O_TEXT is used to indicate write-through on tape devices */
}
status = NtCreateFile (&x, access, &attr, &io, NULL, file_attributes, shared,
- create_disposition, create_options, NULL, 0);
+ create_disposition, create_options, NULL, 0);
if (!NT_SUCCESS (status))
{
if (!wincap.can_open_directories () && pc.isdir ())
}
syscall_printf ("%x = NtCreateFile "
- "(%p, %x, %s, io, NULL, %x, %x, %x, %x, NULL, 0)",
+ "(%p, %x, %s, io, NULL, %x, %x, %x, %x, NULL, 0)",
status, x, access, get_win32_name (), file_attributes, shared,
create_disposition, create_options);
&& current_position >= actual_length + (128 * 1024))
{
/* If the file systemn supports sparse files and the application
- is writing after a long seek beyond EOF, convert the file to
+ is writing after a long seek beyond EOF, convert the file to
a sparse file. */
DWORD dw;
HANDLE h = get_output_handle ();
BOOL r = DeviceIoControl (h, FSCTL_SET_SPARSE, NULL, 0, NULL,
- 0, &dw, NULL);
+ 0, &dw, NULL);
syscall_printf ("%d = DeviceIoControl(%p, FSCTL_SET_SPARSE, "
"NULL, 0, NULL, 0, &dw, NULL)", r, h);
}
else if (wincap.has_lseek_bug ())
{
/* Oops, this is the bug case - Win95 uses whatever is on the
- disk instead of some known (safe) value, so we must seek
+ disk instead of some known (safe) value, so we must seek
back and fill in the gap with zeros. - DJ
- Note: this bug doesn't happen on NT4, even though the
- documentation for WriteFile() says that it *may* happen
+ Note: this bug doesn't happen on NT4, even though the
+ documentation for WriteFile() says that it *may* happen
on any OS. */
char zeros[512];
int number_of_zeros_to_write = current_position - actual_length;
else
{
if (poff_high)
- res += (_off64_t) *poff_high << 32;
+ res += (_off64_t) *poff_high << 32;
/* When next we write(), we will check to see if *this* seek went beyond
the end of the file, and back-seek and fill with zeros if so - DJ */
case 9: /* dim */
dev_state->intensity = INTENSITY_DIM;
break;
- case 10: /* end alternate charset */
- dev_state->alternate_charset_active = false;
+ case 10: /* end alternate charset */
+ dev_state->alternate_charset_active = false;
break;
- case 11: /* start alternate charset */
- dev_state->alternate_charset_active = true;
+ case 11: /* start alternate charset */
+ dev_state->alternate_charset_active = true;
break;
case 24:
dev_state->underline = false;
if (oret)
{
/* We now have a valid handle, regardless of the "nohandle" state.
- Since fhandler_base::open only calls CloseHandle if !nohandle,
+ Since fhandler_base::open only calls CloseHandle if !nohandle,
we have to set it to false before calling close_fs and restore
the state afterwards. */
res = fstat_by_handle (buf);
if (pc.has_attribute (FILE_ATTRIBUTE_COMPRESSED | FILE_ATTRIBUTE_SPARSE_FILE)
&& get_io_handle ()
&& !NtQueryInformationFile (get_io_handle (), &st, (PVOID) &fci,
- sizeof fci, FileCompressionInformation))
+ sizeof fci, FileCompressionInformation))
buf->st_blocks = (fci.CompressedSize.QuadPart + S_BLKSIZE - 1) / S_BLKSIZE;
else
/* Just compute no. of blocks from file size. */
/* symlinks are everything for everyone! */
buf->st_mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
get_file_attribute (pc.has_acls (), get_io_handle (), get_win32_name (),
- NULL, &buf->st_uid, &buf->st_gid);
+ NULL, &buf->st_uid, &buf->st_gid);
goto done;
}
else if (pc.issocket ())
buf->st_mode = S_IFSOCK;
if (!get_file_attribute (pc.has_acls (), get_io_handle (), get_win32_name (),
- &buf->st_mode, &buf->st_uid, &buf->st_gid))
+ &buf->st_mode, &buf->st_uid, &buf->st_gid))
{
/* If read-only attribute is set, modify ntsec return value */
if (pc.has_attribute (FILE_ATTRIBUTE_READONLY) && !pc.issymlink ())
ILLEGAL_UID, ILLEGAL_GID, mode)
&& allow_ntsec)
res = 0;
-
+
if (oret)
close_fs ();
}
if (!pc.has_acls () || !allow_ntsec)
{
/* fake - if not supported, pretend we're like win95
- where it just works */
+ where it just works */
return 0;
}
if (!pc.has_acls () || !allow_ntsec)
{
switch (cmd)
- {
+ {
struct __stat64 st;
case SETACL:
if (!(oret = open_fs (O_BINARY, 0)))
return -1;
}
- if (!fstat_by_handle (&st))
+ if (!fstat_by_handle (&st))
{
aclbufp[0].a_type = USER_OBJ;
aclbufp[0].a_id = st.st_uid;
aclbufp[2].a_type = OTHER_OBJ;
aclbufp[2].a_id = ILLEGAL_GID;
aclbufp[2].a_perm = st.st_mode & S_IRWXO;
- aclbufp[3].a_type = CLASS_OBJ;
+ aclbufp[3].a_type = CLASS_OBJ;
aclbufp[3].a_id = ILLEGAL_GID;
aclbufp[3].a_perm = S_IRWXU | S_IRWXG | S_IRWXO;
res = MIN_ACL_ENTRIES;
if (win32_len == 0)
{
/* Special case if len == 0 for POSIX means lock to the end of
- the entire file (and all future extensions). */
+ the entire file (and all future extensions). */
/* CV, 2003-12-03: And yet another Win 9x bugginess. For some reason
offset + length must be <= 0x100000000. I'm using 0xffffffff as
upper border here, this should be sufficient. */
to the device fails with EBUSY.
If different processes open the audio device simultaneously,
the results are unpredictable - usually the first one wins.
-
+
3. The wave device is reserved within a process from the time that
the first read or write call has been successful until /dev/dsp
has been closed by that process. During this reservation period
bool send (WAVEHDR *); // queue an item, returns true if successful
bool recv (WAVEHDR **); // retrieve an item, returns true if successful
- int query (); // return number of items queued
+ int query (); // return number of items queued
private:
int head_;
queue *Qapp2app_; // empty and unprepared blocks
HWAVEOUT dev_; // The wave device
int bufferIndex_; // offset into pHdr_->lpData
- WAVEHDR *pHdr_; // data to be filled by write
+ WAVEHDR *pHdr_; // data to be filled by write
WAVEHDR wavehdr_[MAX_BLOCKS];
char *bigwavebuffer_; // audio samples only
blockSize = ((bits / 8) * channels * rate) / 8; // approx 125ms per block
// round up to multiple of 64
blockSize += 0x3f;
- blockSize &= ~0x3f;
+ blockSize &= ~0x3f;
return blockSize;
}
debug_printf ("freq=%d bits=%d channels=%d %s", rate, bits, channels,
(rc != MMSYSERR_NOERROR) ? "FAIL" : "OK");
-
+
return (rc == MMSYSERR_NOERROR);
}
{
if (!immediately)
{
- sendcurrent (); // force out last block whatever size..
- waitforallsent (); // block till finished..
+ sendcurrent (); // force out last block whatever size..
+ waitforallsent (); // block till finished..
}
rc = waveOutReset (dev_);
debug_printf ("freq=%d bits=%d channels=%d %s", rate, bits, channels,
(rc != MMSYSERR_NOERROR) ? "FAIL" : "OK");
-
+
return (rc == MMSYSERR_NOERROR);
}
(this->*convert_) ((unsigned char *)pSampleData, bytes_to_read);
nBytes += bytes_to_read;
bufferIndex_ += bytes_to_read;
- debug_printf ("got %d", bytes_to_read);
+ debug_printf ("got %d", bytes_to_read);
break; // done; use remaining data in next call to read
}
else
}
}
pHdr_ = pHdr;
- bufferIndex_ = 0;
+ bufferIndex_ = 0;
}
void
break;
case O_RDONLY:
audio_in_ = new Audio_in;
- if (!audio_in_->query (audiofreq_, audiobits_, audiochannels_))
+ if (!audio_in_->query (audiofreq_, audiobits_, audiochannels_))
{
delete audio_in_;
audio_in_ = NULL;
set_errno (EIO);
}
debug_printf ("ACCMODE=0x%08x audio_in=%08x audio_out=%08x, rc=%d",
- flags & O_ACCMODE, (int)audio_in_, (int)audio_out_, rc);
+ flags & O_ACCMODE, (int)audio_in_, (int)audio_out_, rc);
return rc;
}
{
if (exit_state != ES_NOT_EXITING)
{ // emergency close due to call to exit() or Ctrl-C:
- // do not wait for all pending audio to be played
- audio_out_->stop (true);
+ // do not wait for all pending audio to be played
+ audio_out_->stop (true);
}
delete audio_out_;
audio_out_ = NULL;
CASE (SNDCTL_DSP_SPEED)
{
if (audio_out_)
- {
+ {
RETURN_ERROR_WHEN_BUSY (audio_out_);
audio_out_->stop ();
if (audio_out_->query (*intptr, audiobits_, audiochannels_))
int nChannels = *intptr + 1;
if (audio_out_)
- {
+ {
RETURN_ERROR_WHEN_BUSY (audio_out_);
audio_out_->stop ();
if (audio_out_->query (audiofreq_, audiobits_, nChannels))
int nChannels = *intptr;
if (audio_out_)
- {
+ {
RETURN_ERROR_WHEN_BUSY (audio_out_);
audio_out_->stop ();
if (audio_out_->query (audiofreq_, audiobits_, nChannels))
ret = NtQuerySystemInformation (SystemPagefileInformation, (PVOID) spi,
size, &size);
if (ret == STATUS_INFO_LENGTH_MISMATCH)
- {
+ {
free (spi);
spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (size);
if (spi)
{
PSYSTEM_PAGEFILE_INFORMATION spp = spi;
do
- {
+ {
swap_total += spp->CurrentSize * getpagesize ();
swap_free += (spp->CurrentSize - spp->TotalUsed) * getpagesize ();
}
cpuid (&cpuid_sig, &extra_info, &features2, &features1, 1);
/* unsigned extended_family = (cpuid_sig & 0x0ff00000) >> 20,
extended_model = (cpuid_sig & 0x000f0000) >> 16; */
- unsigned type = (cpuid_sig & 0x00003000) >> 12,
- family = (cpuid_sig & 0x00000f00) >> 8,
- model = (cpuid_sig & 0x000000f0) >> 4,
- stepping = cpuid_sig & 0x0000000f;
- unsigned brand_id = extra_info & 0x0000000f,
- cpu_count = (extra_info & 0x00ff0000) >> 16,
- apic_id = (extra_info & 0xff000000) >> 24;
+ unsigned type = (cpuid_sig & 0x00003000) >> 12,
+ family = (cpuid_sig & 0x00000f00) >> 8,
+ model = (cpuid_sig & 0x000000f0) >> 4,
+ stepping = cpuid_sig & 0x0000000f;
+ unsigned brand_id = extra_info & 0x0000000f,
+ cpu_count = (extra_info & 0x00ff0000) >> 16,
+ apic_id = (extra_info & 0xff000000) >> 24;
const char *type_str;
switch (type)
{
continue;
char devname[16];
__small_sprintf (devname, "/dev/sd%c%d",
- drive_number + 'a',
+ drive_number + 'a',
partition + 1);
device dev;
dev.parse (devname);
if (is_eom (ret))
set_errno (ENOSPC);
else
- __seterrno ();
+ __seterrno ();
goto err;
}
set_errno (EINVAL);
return -1;
}
-
+
if (!PurgeComm (get_handle (), flags))
{
__seterrno ();
{
cygheap_fdnew res_fd;
if (res_fd >= 0 && fdsock (res_fd, &dev (), res))
- {
+ {
if (get_addr_family () == AF_LOCAL)
((fhandler_socket *) res_fd)->set_sun_path (get_sun_path ());
((fhandler_socket *) res_fd)->set_addr_family (get_addr_family ());
switch (WSAWaitForMultipleEvents (2, ev, FALSE, 10, FALSE))
{
case WSA_WAIT_TIMEOUT:
- ret = 0;
+ ret = 0;
break;
case WSA_WAIT_EVENT_0:
if (!WSAEnumNetworkEvents (get_socket (), event, &evts))
{
if (!evts.lNetworkEvents)
{
- ret = 0;
+ ret = 0;
break;
}
if (evts.lNetworkEvents & FD_OOB)
}
break;
case WSA_WAIT_EVENT_0 + 1:
- WSASetLastError (WSAEINTR);
+ WSASetLastError (WSAEINTR);
break;
default:
WSASetLastError (WSAEFAULT);
HANDLE evt;
if (prepare (evt, FD_CLOSE | FD_READ | (owner () ? FD_OOB : 0)))
{
- do
- {
+ do
+ {
DWORD lflags = (DWORD) flags;
res = WSARecvFrom (get_socket (), &wsabuf, 1, &ret, &lflags,
from, fromlen, NULL, NULL);
- }
- while (res == SOCKET_ERROR
- && WSAGetLastError () == WSAEWOULDBLOCK
+ }
+ while (res == SOCKET_ERROR
+ && WSAGetLastError () == WSAEWOULDBLOCK
&& !closed ()
&& !(res = wait (evt, flags)));
release (evt);
HANDLE evt;
if (prepare (evt, FD_CLOSE | FD_READ | (owner () ? FD_OOB : 0)))
{
- do
- {
+ do
+ {
DWORD lflags = (DWORD) flags;
res = WSARecvFrom (get_socket (), wsabuf, iovcnt, &ret,
&lflags, from, fromlen, NULL, NULL);
- }
- while (res == SOCKET_ERROR
+ }
+ while (res == SOCKET_ERROR
&& WSAGetLastError () == WSAEWOULDBLOCK
&& !closed ()
&& !(res = wait (evt, flags)));
HANDLE evt;
if (prepare (evt, FD_CLOSE | FD_WRITE | (owner () ? FD_OOB : 0)))
{
- do
+ do
{
res = WSASendTo (get_socket (), &wsabuf, 1, &ret,
flags & MSG_WINMASK,
tolen, NULL, NULL);
}
while (res == SOCKET_ERROR
- && WSAGetLastError () == WSAEWOULDBLOCK
+ && WSAGetLastError () == WSAEWOULDBLOCK
&& !(res = wait (evt, 0))
&& !closed ());
release (evt);
HANDLE evt;
if (prepare (evt, FD_CLOSE | FD_WRITE | (owner () ? FD_OOB : 0)))
{
- do
- {
+ do
+ {
res = WSASendTo (get_socket (), wsabuf, iovcnt,
- &ret, flags,
+ &ret, flags,
(struct sockaddr *) msg->msg_name,
msg->msg_namelen, NULL, NULL);
- }
- while (res == SOCKET_ERROR
- && WSAGetLastError () == WSAEWOULDBLOCK
+ }
+ while (res == SOCKET_ERROR
+ && WSAGetLastError () == WSAEWOULDBLOCK
&& !(res = wait (evt, 0))
- && !closed ());
+ && !closed ());
release (evt);
}
}
case FIONREAD:
res = ioctlsocket (get_socket (), FIONREAD, (unsigned long *) p);
if (res == SOCKET_ERROR)
- set_winsock_errno ();
+ set_winsock_errno ();
break;
default:
/* We must cancel WSAAsyncSelect (if any) before setting socket to
if (dirty == async_write_pending)
lasterr = async_wait (mt, NULL);
if (!lasterr)
- {
+ {
/* if last operation was writing, write a filemark */
debug_printf ("writing filemark");
write_marks (mt, TAPE_FILEMARKS, two_fm () ? 2 : 1);
else if (dirty == has_read && !rewind)
{
if (sysv ())
- {
+ {
/* Under SYSV semantics, the tape is moved past the next file mark
after read. */
if (part (partition)->emark == no_eof)
part (partition)->emark = eof;
}
else
- {
+ {
/* Under BSD semantics, we must check if the filemark has been
inadvertendly crossed. If so cross the filemark backwards
and position the tape right before EOF. */
else if (IS_EOD (lasterr))
{
if (part (partition)->emark == eof)
- part (partition)->emark = IS_EOM (lasterr) ? eom : eod;
+ part (partition)->emark = IS_EOM (lasterr) ? eom : eod;
else
- {
+ {
part (partition)->emark = IS_EOM (lasterr) ? eom_hit : eod_hit;
lasterr = 0;
}
/* This happens if the buffer is too small when in variable block
size mode. Linux returns ENOMEM here. We're doing the same. */
if (lasterr == ERROR_MORE_DATA)
- lasterr = ERROR_NOT_ENOUGH_MEMORY;
+ lasterr = ERROR_NOT_ENOUGH_MEMORY;
}
if (!lasterr)
dirty = has_read;
if (lasterr == ERROR_IO_PENDING)
{
if (async_writes () && mp ()->BlockSize == 0)
- dirty = async_write_pending;
+ dirty = async_write_pending;
else
/* Wait for completion if a non-async write. */
lasterr = async_wait (mt, &bytes_written);
{
part (partition)->emark = no_eof;
if (!lasterr)
- dirty = has_written;
+ dirty = has_written;
else if (lasterr == ERROR_IO_PENDING)
- dirty = async_write_pending;
+ dirty = async_write_pending;
}
return error ("write");
}
partition = (long) p - 1;
block = (long) low;
if (ppartition)
- *ppartition= partition;
+ *ppartition= partition;
if (pblock)
- *pblock = block;
+ *pblock = block;
}
else
{
case TAPE_SPACE_RELATIVE_BLOCKS:
case TAPE_SPACE_FILEMARKS:
case TAPE_SPACE_SETMARKS:
- if (!count)
+ if (!count)
{
lasterr = 0;
goto out;
case TAPE_ABSOLUTE_BLOCK:
case TAPE_LOGICAL_BLOCK:
case TAPE_REWIND:
- dont_wait = nowait () ? TRUE : FALSE;
+ dont_wait = nowait () ? TRUE : FALSE;
break;
}
if (mode == TAPE_SPACE_FILEMARKS)
case TAPE_LOGICAL_BLOCK:
get_pos (mt);
part (partition)->initialize (block);
- break;
+ break;
case TAPE_REWIND:
- if (!err)
+ if (!err)
{
block = 0;
part (partition)->initialize (0);
get_pos (mt);
part (partition)->initialize (block);
part (partition)->emark = IS_EOM (err) ? eom : eod;
- break;
+ break;
case TAPE_SPACE_FILEMARKS:
if (!err || IS_SM (err))
{
}
else
{
- if (part (partition)->file >= 0)
+ if (part (partition)->file >= 0)
part (partition)->file += count - undone;
part (partition)->fblock = -1;
part (partition)->smark = false;
block = 0;
part (partition)->initialize (0);
}
- break;
+ break;
case TAPE_SPACE_SETMARKS:
get_pos (mt);
part (partition)->block = block;
- if (!err)
+ if (!err)
{
part (partition)->file = -1;
part (partition)->fblock = -1;
part (partition)->smark = true;
}
- break;
+ break;
}
lasterr = err;
out:
if (get_feature (TAPE_DRIVE_INITIATOR))
{
if (count <= 0)
- TAPE_FUNC (CreateTapePartition (mt, TAPE_INITIATOR_PARTITIONS,
+ TAPE_FUNC (CreateTapePartition (mt, TAPE_INITIATOR_PARTITIONS,
count <= 0 ? 0 : 2, (DWORD) count));
}
else if (get_feature (TAPE_DRIVE_FIXED))
{
/* This is supposed to work for Tandberg SLR drivers up to version
- 1.6 which missed to set the TAPE_DRIVE_INITIATOR flag. According
+ 1.6 which missed to set the TAPE_DRIVE_INITIATOR flag. According
to Tandberg, CreateTapePartition(TAPE_FIXED_PARTITIONS) apparently
does not ignore the dwCount parameter. Go figure! */
TAPE_FUNC (CreateTapePartition (mt, TAPE_FIXED_PARTITIONS,
if (sav_partition != partition)
{
if (partition < MAX_PARTITION_NUM
- && part (partition)->block != block)
+ && part (partition)->block != block)
part (partition)->initialize (block);
}
else if (sav_block != block && partition < MAX_PARTITION_NUM)
lasterr = err;
}
else
- {
+ {
partition = count;
if (part (partition)->block == -1)
part (partition)->initialize (0);
break;
case TAPE_LOCK:
lock = lasterr ? lock_error : is_auto ? auto_locked : locked;
- break;
+ break;
case TAPE_UNLOCK:
- lock = lasterr ? lock_error : unlocked;
+ lock = lasterr ? lock_error : unlocked;
break;
}
return error ("prepare");
else
get->mt_gstat |= GMT_EOF (-1);
if (part (partition)->emark >= eod_hit)
- get->mt_gstat |= GMT_EOD (-1);
+ get->mt_gstat |= GMT_EOD (-1);
if (part (partition)->emark >= eom_hit)
- get->mt_gstat |= GMT_EOT (-1);
+ get->mt_gstat |= GMT_EOT (-1);
if (part (partition)->smark)
- get->mt_gstat |= GMT_SM (-1);
+ get->mt_gstat |= GMT_SM (-1);
get->mt_gstat |= GMT_ONLINE (-1);
{
buffer_writes ((options == 1));
}
- break;
+ break;
case MT_ST_BOOLEANS:
buffer_writes (!!(options & MT_ST_BUFFER_WRITES));
async_writes (!!(options & MT_ST_ASYNC_WRITES));
if (sdp.ECC != dp ()->ECC || sdp.DataPadding != dp ()->DataPadding
|| sdp.ReportSetmarks != dp ()->ReportSetmarks)
call_setparams = true;
- break;
+ break;
case MT_ST_SETBOOLEANS:
case MT_ST_CLEARBOOLEANS:
- set = (what == MT_ST_SETBOOLEANS);
+ set = (what == MT_ST_SETBOOLEANS);
if (options & MT_ST_BUFFER_WRITES)
buffer_writes (set);
if (options & MT_ST_ASYNC_WRITES)
if (sdp.ECC != dp ()->ECC || sdp.DataPadding != dp ()->DataPadding
|| sdp.ReportSetmarks != dp ()->ReportSetmarks)
call_setparams = true;
- break;
+ break;
case MT_ST_EOT_WZ_SIZE:
if (get_feature (TAPE_DRIVE_SET_EOT_WZ_SIZE))
{
if (sdp.EOTWarningZoneSize != dp ()->EOTWarningZoneSize)
call_setparams = true;
}
- break;
+ break;
}
if (call_setparams)
{
TAPE_FUNC (SetTapeParameters (mt, SET_TAPE_DRIVE_INFORMATION, &sdp));
int err = lasterr;
if (!err)
- {
+ {
dp ()->ECC = sdp.ECC;
dp ()->DataPadding = sdp.DataPadding;
dp ()->ReportSetmarks = sdp.ReportSetmarks;
if (cmd == MTIOCTOP)
{
if (__check_invalid_read_ptr (buf, sizeof (struct mtop)))
- return ERROR_NOACCESS;
+ return ERROR_NOACCESS;
struct mtop *op = (struct mtop *) buf;
if (lasterr == ERROR_BUS_RESET)
- {
+ {
/* If a bus reset occurs, block further access to this device
until the user rewinds, unloads or in any other way tries
to maintain a well-known tape position. */
debug_printf ("Couldn't relock drive after bus reset.");
lock = unlocked;
}
- }
+ }
switch (op->mt_op)
{
case MTRESET:
else if (cmd == MTIOCGET)
{
if (__check_null_invalid_struct (buf, sizeof (struct mtget)))
- return ERROR_NOACCESS;
+ return ERROR_NOACCESS;
get_status (mt, (struct mtget *) buf);
}
else if (cmd == MTIOCPOS)
{
if (__check_null_invalid_struct (buf, sizeof (struct mtpos)))
- return ERROR_NOACCESS;
+ return ERROR_NOACCESS;
if (!get_pos (mt))
((struct mtpos *) buf)->mt_blkno = block;
}
magic = MTINFO_MAGIC;
version = MTINFO_VERSION;
for (unsigned i = 0; i < MAX_DRIVE_NUM; ++i)
- drive (i)->initialize (i, true);
+ drive (i)->initialize (i, true);
ReleaseMutex (mtx);
CloseHandle (mtx);
}
api_fatal ("MT magic number screwed up: %lu, should be %lu",
magic, MTINFO_MAGIC);
if (version != MTINFO_VERSION)
- system_printf ("MT version number mismatch: %lu, should be %lu",
+ system_printf ("MT version number mismatch: %lu, should be %lu",
version, MTINFO_VERSION);
}
}
buf += bytes_to_read;
devbufstart += bytes_to_read;
if (devbufstart == devbufend)
- devbufstart = devbufend = 0;
+ devbufstart = devbufend = 0;
/* If a switch to variable block_size occured, just return the buffer
- remains until the buffer is empty, then proceed with usual variable
+ remains until the buffer is empty, then proceed with usual variable
block size handling (one block per read call). */
if (!block_size)
- len = 0;
+ len = 0;
}
if (len > 0)
{
debug_printf ("Creating event failed: %E");
size_t block_fit = !block_size ? len : rounddown(len, block_size);
if (block_fit)
- {
+ {
debug_printf ("read %d bytes from tape (rest %d)",
block_fit, len - block_fit);
ret = mt->drive (driveno ())->read (get_handle (), mt_evt, buf,
buf += block_fit;
/* Only one block in each read call, please. */
if (!block_size)
- len = 0;
+ len = 0;
}
else {
len = 0;
}
}
if (!ret && len > 0)
- {
+ {
debug_printf ("read %d bytes from tape (one block)", block_size);
ret = mt->drive (driveno ())->read (get_handle (), mt_evt, devbuf,
block_size);
goto out;
/* DISCARD (FLUSHO) and tcflush can finish here. */
if (n == 0 && (get_ttyp ()->ti.c_lflag & FLUSHO || !buf))
- goto out;
+ goto out;
if (n == 0 && is_nonblocking ())
{
set_errno (EAGAIN);
termios_printf ("SetProcessWindowStation %d, %E", b);
}
b = AllocConsole (); // will cause flashing if workstation
- // stuff fails
+ // stuff fails
termios_printf ("%d = AllocConsole (), %E", b);
if (b)
init_console_handler ();
/* On first peek determine no. of bytes to flush. */
if (!ptr && len == UINT_MAX)
- len = (size_t) bytes_in_pipe;
+ len = (size_t) bytes_in_pipe;
if (ptr && !vmin && !time_to_wait)
{
len -= n;
totalread += n;
if (ptr)
- {
+ {
memcpy (ptr, buf, n);
ptr = (char *) ptr + n;
}
if (!bytes_in_pipe)
break;
continue;
- }
+ }
if (get_ttyp ()->read_retval < 0) // read error
{
return -1;
console->init (INVALID_HANDLE_VALUE, GENERIC_READ | GENERIC_WRITE, O_BINARY);
- cygheap->open_fhs--; /* handled when individual fds are opened */
+ cygheap->open_fhs--; /* handled when individual fds are opened */
console->uninterruptible_io (true);
return 0;
}
return ERANGE;
struct __group32 *tempgr = internal_getgrgid (gid, true);
- pthread_testcancel ();
+ pthread_testcancel ();
if (!tempgr)
return 0;
return ERANGE;
struct __group32 *tempgr = internal_getgrnam (nam, true);
- pthread_testcancel ();
+ pthread_testcancel ();
if (!tempgr)
return 0;
for (DWORD pg = 0; pg < groups->GroupCount; ++pg)
if (sid == groups->Groups[pg].Sid &&
sid != well_known_world_sid)
- {
+ {
if (cnt < gidsetsize)
grouplist[cnt] = gr->gr_gid;
++cnt;
newbrksize = commitbytes;
if ((VirtualAlloc (cygheap->user_heap.top, newbrksize, MEM_RESERVE, PAGE_NOACCESS)
- || VirtualAlloc (cygheap->user_heap.top, newbrksize = commitbytes, MEM_RESERVE, PAGE_NOACCESS))
+ || VirtualAlloc (cygheap->user_heap.top, newbrksize = commitbytes, MEM_RESERVE, PAGE_NOACCESS))
&& VirtualAlloc (cygheap->user_heap.top, commitbytes, MEM_COMMIT, PAGE_READWRITE) != NULL)
{
cygheap->user_heap.max = (char *) cygheap->user_heap.max + pround (newbrksize);
/* no need for the overhead */;
else
{
- for (i = 0; threadfunc_ix[i]; i++)
+ for (i = 0; threadfunc_ix[i]; i++)
ebp[threadfunc_ix[i]] = (char *) threadfunc_fe;
((char **) _tlsbase)[OLDFUNC_OFFSET] = threadfunc;
}
* SUCH DAMAGE.
*
* CV 2003-09-10: Cygwin specific changes applied. Code simplified just
- * for Cygwin alone.
+ * for Cygwin alone.
*/
#include "winsup.h"
if ((fdname = ttyname (fd)))
{
if (fd != STDIN_FILENO)
- close (STDIN_FILENO);
+ close (STDIN_FILENO);
if (fd != STDOUT_FILENO)
- close (STDOUT_FILENO);
+ close (STDOUT_FILENO);
if (fd != STDERR_FILENO)
- close (STDERR_FILENO);
+ close (STDERR_FILENO);
newfd = open (fdname, O_RDWR);
close (newfd);
}
strcpy (pts, ptsname (master));
revoke (pts);
if ((slave = open (pts, O_RDWR | O_NOCTTY)) >= 0)
- {
+ {
if (amaster)
*amaster = master;
if (aslave)
if (!check_null_str_errno (newprogname))
{
/* Per BSD man page, setprogname keeps a pointer to the last
- path component of the argument. It does *not* copy the
+ path component of the argument. It does *not* copy the
argument before. */
__progname = strrchr (newprogname, '/');
if (__progname)
- ++__progname;
+ ++__progname;
else
__progname = (char *)newprogname;
}
case IPC_STAT:
if (__check_null_invalid_struct_errno (buf, sizeof *buf))
return -1;
- break;
+ break;
case IPC_SET:
if (__check_invalid_read_ptr_errno (buf, sizeof *buf))
return -1;
- break;
+ break;
case IPC_RMID:
- break;
+ break;
case IPC_INFO:
/* msqid == 0: Request for msginfo struct. */
if (!msqid
&& __check_null_invalid_struct_errno (buf, sizeof (struct msginfo)))
return -1;
/* Otherwise, request msqid entries from internal msqid_ds array. */
- if (msqid)
+ if (msqid)
if (__check_null_invalid_struct_errno (buf, msqid * sizeof (struct msqid_ds)))
return -1;
- break;
+ break;
case MSG_INFO:
- if (__check_null_invalid_struct_errno (buf, sizeof (struct msg_info)))
+ if (__check_null_invalid_struct_errno (buf, sizeof (struct msg_info)))
return -1;
- break;
+ break;
default:
- syscall_printf ("-1 [%d] = msgctl ()", EINVAL);
+ syscall_printf ("-1 [%d] = msgctl ()", EINVAL);
set_errno (EINVAL);
return -1;
}
syscall_printf ("-1 [%d] = msgctl ()", request.error_code ());
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return -1;
}
return request.retval ();
syscall_printf ("-1 [%d] = msgget ()", request.error_code ());
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return -1;
}
return request.retval ();
{
#ifdef USE_SERVER
syscall_printf ("msgrcv (msqid = %d, msgp = %p, msgsz = %d, "
- "msgtyp = %d, msgflg = 0x%x)",
+ "msgtyp = %d, msgflg = 0x%x)",
msqid, msgp, msgsz, msgtyp, msgflg);
if (__check_null_invalid_struct_errno (msgp, msgsz))
return -1;
syscall_printf ("-1 [%d] = msgrcv ()", request.error_code ());
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return -1;
}
return request.rcvval ();
syscall_printf ("-1 [%d] = msgsnd ()", request.error_code ());
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return -1;
}
return request.retval ();
inline int error (const char *str)
{
if (lasterr)
- debug_printf ("%s: Win32 error %d", lasterr);
+ debug_printf ("%s: Win32 error %d", lasterr);
return lasterr;
}
inline bool get_feature (DWORD parm)
cygheap_fdnew res_fd;
if (res_fd >= 0 && fdsock (res_fd, tcp_dev, res))
- res = res_fd;
+ res = res_fd;
else
res = -1;
}
!internal_getpwuid (myself->uid))))
{
static char linebuf[1024]; // must be static and
- // should not be NO_COPY
+ // should not be NO_COPY
(void) cygheap->user.ontherange (CH_HOME, NULL);
snprintf (linebuf, sizeof (linebuf), "%s:*:%lu:%lu:,%s:%s:/bin/sh",
cygheap->user.name (),
PUNICODE_STRING
path_conv::get_nt_native_path (UNICODE_STRING &upath, WCHAR *wpath)
{
- if (path[0] != '\\') /* X:\... or NUL, etc. */
+ if (path[0] != '\\') /* X:\... or NUL, etc. */
{
str2buf2uni (upath, wpath, "\\??\\");
str2buf2uni_cat (upath, path);
}
- else if (path[1] != '\\') /* \Device\... */
+ else if (path[1] != '\\') /* \Device\... */
str2buf2uni (upath, wpath, path);
- else if (path[2] != '.'
- || path[3] != '\\') /* \\server\share\... */
+ else if (path[2] != '.'
+ || path[3] != '\\') /* \\server\share\... */
{
str2buf2uni (upath, wpath, "\\??\\UNC\\");
str2buf2uni_cat (upath, path + 2);
- }
- else /* \\.\device */
+ }
+ else /* \\.\device */
{
str2buf2uni (upath, wpath, "\\??\\");
str2buf2uni_cat (upath, path + 4);
into account during processing */
if (tail > path_copy + 1)
{
- if (isslash (tail[-1]))
- {
+ if (isslash (tail[-1]))
+ {
need_directory = 1;
tail--;
}
- /* Remove trailing dots and spaces which are ignored by Win32 functions but
+ /* Remove trailing dots and spaces which are ignored by Win32 functions but
not by native NT functions. */
- while (tail[-1] == '.' || tail[-1] == ' ')
+ while (tail[-1] == '.' || tail[-1] == ' ')
tail--;
- if (tail > path_copy + 1 && isslash (tail[-1]))
- {
+ if (tail > path_copy + 1 && isslash (tail[-1]))
+ {
error = ENOENT;
- return;
+ return;
}
- }
+ }
path_end = tail;
*tail = '\0';
else if (src[0] == '.' && src[1] == '.'
/* dst must be greater than dst_start */
&& dst[-1] == '\\')
- {
+ {
if (isdirsep (src[2]) || src[2] == 0)
{
/* Back up over /, but not if it's the first one. */
defeat the Windows 95 (i.e. MS-DOS) tendency of returning to
the last directory visited on the given drive. */
if (isdrive (native_dir) && !native_dir[2])
- {
+ {
path.get_win32 ()[2] = '\\';
path.get_win32 ()[3] = '\0';
}
The posix_cwd is just path.normalized_path.
In other cases we let cwd.set obtain the Posix path through
the mount table. */
- if (!path.has_symlinks () && !isabspath (in_dir))
+ if (!isdrive(path.normalized_path))
posix_cwd = path.normalized_path;
res = 0;
doit = true;
{
cwd_lock->acquire ();
if (doit && !SetCurrentDirectory (win32_cwd))
- {
- __seterrno ();
- goto out;
- }
+ {
+ __seterrno ();
+ goto out;
+ }
}
/* If there is no win32 path or it has the form c:xxx, get the value */
if (!win32_cwd || (isdrive (win32_cwd) && win32_cwd[2] != '\\'))
int i;
DWORD len, dlen;
for (i = 0, dlen = CYG_MAX_PATH/3; i < 2; i++, dlen = len)
- {
+ {
win32 = (char *) crealloc (win32, dlen);
if ((len = GetCurrentDirectoryA (dlen, win32)) < dlen)
break;
}
if (len == 0)
- {
+ {
__seterrno ();
debug_printf ("GetCurrentDirectory, %E");
win32_cwd = pathbuf; /* Force lock release */
{
case -1: /* Something weird happened */
/* When select returns that data is available,
- that could mean that the socket is in
+ that could mean that the socket is in
listen mode and a client tries to connect.
Unfortunately, recvfrom() doesn't make much
sense then. It returns WSAENOTCONN in that
forprocid = 0;
reg_key reg (HKEY_LOCAL_MACHINE, KEY_READ, "SYSTEM", "CurrentControlSet",
- "Control", "PriorityControl", NULL);
+ "Control", "PriorityControl", NULL);
if (reg.error ())
{
set_errno (ESRCH);
{
int res = 2 + set_process_privilege (SE_RESTORE_NAME, true, issetuid);
if (!issetuid)
- saved_res = res;
+ saved_res = res;
}
}
of the SD on success. Unfortunately NT returns
0 in `len' on success, while W2K returns the
correct size!
-
+
2003-11-26: Now the function allocates the space needed by itself so
it knows the real size and returns it in the security_descriptor object.
*/
NULL)) == INVALID_HANDLE_VALUE)
break;
if (fh && (ret = NtSetSecurityObject (fh,
- DACL_SECURITY_INFORMATION
+ DACL_SECURITY_INFORMATION
| GROUP_SECURITY_INFORMATION
| OWNER_SECURITY_INFORMATION,
sd)) == STATUS_SUCCESS)
InitializeSecurityDescriptor ((PSECURITY_DESCRIPTOR)psa->lpSecurityDescriptor,
SECURITY_DESCRIPTOR_REVISION);
psa->lpSecurityDescriptor = alloc_sd (geteuid32 (), getegid32 (),
- attribute, sd);
+ attribute, sd);
}
static int
syscall_printf ("-1 [%d] = semctl ()", request.error_code ());
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return -1;
}
return request.retval ();
syscall_printf ("-1 [%d] = semget ()", request.error_code ());
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return -1;
}
return request.retval ();
syscall_printf ("-1 [%d] = semop ()", request.error_code ());
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return -1;
}
return request.retval ();
if (!name)
mapname = NULL;
else
- mapname = shared_name (map_buf, name, n);
+ mapname = shared_name (map_buf, name, n);
if (!(shared_h = CreateFileMapping (INVALID_HANDLE_VALUE, psa,
PAGE_READWRITE, 0, size, mapname)))
api_fatal ("CreateFileMapping %s, %E. Terminating.", mapname);
if (!cygwin_user_h)
{
if (wincap.has_security ())
- {
+ {
cygpsid tu (cygheap->user.sid ());
tu.string (name);
}
SLIST_FOREACH (sph_entry, &sph_list, sph_next)
{
vm_object_t ptr = MapViewOfFileEx(sph_entry->hdl, sph_entry->access,
- 0, 0, sph_entry->size, sph_entry->ptr);
+ 0, 0, sph_entry->size, sph_entry->ptr);
if (ptr != sph_entry->ptr)
- api_fatal ("MapViewOfFileEx (%p), %E. Terminating.", sph_entry->ptr);
+ api_fatal ("MapViewOfFileEx (%p), %E. Terminating.", sph_entry->ptr);
}
return 0;
}
if (!ssh_entry)
{
/* The shmid is unknown to this process so far. Try to get it from
- the server if it exists. Use special internal call to shmget,
+ the server if it exists. Use special internal call to shmget,
which interprets the key as a shmid and only returns a valid
shmid if one exists. Since shmctl inserts a new entry for this
shmid into ssh_list automatically, we just have to go through
that list again. If that still fails, well, bad luck. */
if (shmid && shmget ((key_t) shmid, 0, IPC_KEY_IS_SHMID) != -1)
- {
+ {
SLIST_FOREACH (ssh_entry, &ssh_list, ssh_next)
{
if (ssh_entry->shmid == shmid)
}
}
if (!ssh_entry)
- {
+ {
/* Invalid shmid */
set_errno (EINVAL);
return (void *) -1;
if (shmaddr)
{
if (shmflg & SHM_RND)
- attach_va = (vm_object_t)((vm_offset_t)shmaddr & ~(SHMLBA-1));
+ attach_va = (vm_object_t)((vm_offset_t)shmaddr & ~(SHMLBA-1));
else
attach_va = (vm_object_t)shmaddr;
/* Don't even bother to call anything if shmaddr is NULL or
- not aligned. */
+ not aligned. */
if (!attach_va || (vm_offset_t)attach_va % SHMLBA)
{
set_errno (EINVAL);
delete sph_entry;
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return (void *) -1;
}
sph_entry->ptr = ptr;
case IPC_SET:
if (__check_null_invalid_struct_errno (buf, sizeof (struct shmid_ds)))
return -1;
- break;
+ break;
case IPC_INFO:
/* shmid == 0: Request for shminfo struct. */
if (!shmid
if (shmid)
if (__check_null_invalid_struct_errno (buf, shmid * sizeof (struct shmid_ds)))
return -1;
- break;
+ break;
case SHM_INFO:
- if (__check_null_invalid_struct_errno (buf, sizeof (struct shm_info)))
+ if (__check_null_invalid_struct_errno (buf, sizeof (struct shm_info)))
return -1;
- break;
+ break;
}
client_request_shm request (shmid, cmd, buf);
if (request.make_request () == -1 || request.retval () == -1)
syscall_printf ("-1 [%d] = shmctl ()", request.error_code ());
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return -1;
}
if (cmd == IPC_RMID)
/* The process must cleanup its own storage... */
shm_shmid_list *ssh_entry, *ssh_next_entry;
SLIST_FOREACH_SAFE (ssh_entry, &ssh_list, ssh_next, ssh_next_entry)
- {
+ {
if (ssh_entry->shmid == shmid)
{
SLIST_REMOVE (&ssh_list, ssh_entry, shm_shmid_list, ssh_next);
syscall_printf ("-1 [%d] = shmdt ()", request.error_code ());
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return -1;
}
shm_attached_list *sph_entry, *sph_next_entry;
SLIST_FOREACH_SAFE (sph_entry, &sph_list, sph_next, sph_next_entry)
{
if (sph_entry->ptr == shmaddr)
- {
+ {
SLIST_REMOVE (&sph_list, sph_entry, shm_attached_list, sph_next);
/* ...and unmap view. */
UnmapViewOfFile (sph_entry->ptr);
delete ssh_new_entry;
set_errno (request.error_code ());
if (request.error_code () == ENOSYS)
- raise (SIGSYS);
+ raise (SIGSYS);
return -1;
}
int shmid = request.retval (); /* Shared mem ID */
SLIST_FOREACH (ssh_entry, &ssh_list, ssh_next)
{
if (ssh_entry->shmid == shmid)
- {
+ {
/* We already maintain an entry for this shmid. That means,
the hdl returned by cygserver is a superfluous duplicate
of the original hdl maintained by cygserver. We can safely
scan_wait:
/* Scan the linked list of wait()ing threads. If a wait's parameters
- match this pid, then activate it. */
+ match this pid, then activate it. */
for (w = &waitq_head; w->next != NULL; w = w->next)
{
if ((potential_match = checkstate (w)) > 0)
if (!WriteFile (sendsig, &pack, sizeof (pack), &nb, NULL) || nb != sizeof (pack))
{
/* Couldn't send to the pipe. This probably means that the
- process is exiting. */
+ process is exiting. */
if (!its_me)
{
sigproc_printf ("WriteFile for pipe %p failed, %E", sendsig);
fhandler_base *fh;
if (!(fh = build_fh_name (path, NULL, PC_SYM_FOLLOW, stat_suffixes)))
goto error;
-
+
if (fh->error ())
{
debug_printf ("got %d error from build_fh_name", fh->error ());
if (check_null_invalid_struct_errno (buf))
goto error;
- if (!(fh = build_fh_name (name, NULL, nofollow ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW,
+ if (!(fh = build_fh_name (name, NULL, nofollow ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW,
stat_suffixes)))
goto error;
-
+
if (fh->error ())
{
debug_printf ("got %d error from build_fh_name", fh->error ());
{
fhandler_base *fh = build_fh_name (fn, NULL, PC_SYM_FOLLOW, stat_suffixes);
if (fh)
- {
+ {
res = fh->fhaccess (flags);
delete fh;
}
else if (buflen < strlen (cfd->ttyname ()) + 1)
ret = ERANGE;
else
- strcpy (buf, cfd->ttyname ());
+ strcpy (buf, cfd->ttyname ());
}
debug_printf ("returning %d tty: %s", ret, ret ? "NULL" : buf);
return ret;
case _SC_SAVED_IDS:
return _POSIX_SAVED_IDS;
case _SC_LOGIN_NAME_MAX:
- return LOGIN_NAME_MAX;
+ return LOGIN_NAME_MAX;
case _SC_GETPW_R_SIZE_MAX:
case _SC_GETGR_R_SIZE_MAX:
return 16*1024;
}
break;
case _SC_AVPHYS_PAGES:
- if (wincap.supports_smp ())
+ if (wincap.supports_smp ())
{
NTSTATUS ret;
SYSTEM_PERFORMANCE_INFORMATION spi;
case _SC_RTSIG_MAX:
return RTSIG_MAX;
case _SC_TTY_NAME_MAX:
- return TTY_NAME_MAX;
+ return TTY_NAME_MAX;
}
/* Invalid input or unimplemented sysconf name */
{
thread = new pthread ();
if (!thread)
- api_fatal ("failed to create mainthread object");
+ api_fatal ("failed to create mainthread object");
}
set_tls_self_pointer (thread);
pthread_mutex::is_good_initializer (pthread_mutex_t const *mutex)
{
if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC,
- PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
- PTHREAD_NORMAL_MUTEX_INITIALIZER_NP,
- PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) != VALID_STATIC_OBJECT)
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
+ PTHREAD_NORMAL_MUTEX_INITIALIZER_NP,
+ PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) != VALID_STATIC_OBJECT)
return false;
return true;
}
pthread_mutex::is_good_initializer_or_object (pthread_mutex_t const *mutex)
{
if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC,
- PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
- PTHREAD_NORMAL_MUTEX_INITIALIZER_NP,
- PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) == INVALID_OBJECT)
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
+ PTHREAD_NORMAL_MUTEX_INITIALIZER_NP,
+ PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) == INVALID_OBJECT)
return false;
return true;
}
pthread_mutex::is_good_initializer_or_bad_object (pthread_mutex_t const *mutex)
{
if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC,
- PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
- PTHREAD_NORMAL_MUTEX_INITIALIZER_NP,
- PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) == VALID_OBJECT)
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
+ PTHREAD_NORMAL_MUTEX_INITIALIZER_NP,
+ PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) == VALID_OBJECT)
return false;
return true;
}
unsigned int value)
: verifyable_object (SEM_MAGIC),
shared (PTHREAD_PROCESS_SHARED),
- currentvalue (value), /* Unused for named semaphores. */
+ currentvalue (value), /* Unused for named semaphores. */
name (NULL)
{
if (oflag & O_CREAT)
verifyable_object_state
verifyable_object_isvalid (void const * objectptr, long magic, void *static_ptr1,
- void *static_ptr2, void *static_ptr3)
+ void *static_ptr2, void *static_ptr3)
{
verifyable_object **object = (verifyable_object **)objectptr;
if (check_valid_pointer (object))
int
pthread_mutex::init (pthread_mutex_t *mutex,
- const pthread_mutexattr_t *attr,
- const pthread_mutex_t initializer)
+ const pthread_mutexattr_t *attr,
+ const pthread_mutex_t initializer)
{
pthread_mutex_t new_mutex;
if (!attr && initializer)
{
if (initializer == PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
- new_mutex->type = PTHREAD_MUTEX_RECURSIVE;
+ new_mutex->type = PTHREAD_MUTEX_RECURSIVE;
else if (initializer == PTHREAD_NORMAL_MUTEX_INITIALIZER_NP)
- new_mutex->type = PTHREAD_MUTEX_NORMAL;
+ new_mutex->type = PTHREAD_MUTEX_NORMAL;
else if (initializer == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP)
- new_mutex->type = PTHREAD_MUTEX_ERRORCHECK;
+ new_mutex->type = PTHREAD_MUTEX_ERRORCHECK;
}
*mutex = new_mutex;
} verifyable_object_state;
verifyable_object_state verifyable_object_isvalid (void const * objectptr, long magic,
- void *static_ptr1 = NULL,
- void *static_ptr2 = NULL,
- void *static_ptr3 = NULL);
+ void *static_ptr1 = NULL,
+ void *static_ptr2 = NULL,
+ void *static_ptr3 = NULL);
template <class list_node> inline void
List_insert (list_node *&head, list_node *node)
static bool can_be_unlocked (pthread_mutex_t const *mutex);
static void init_mutex ();
static int init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr,
- const pthread_mutex_t initializer = NULL);
+ const pthread_mutex_t initializer = NULL);
unsigned long lock_counter;
HANDLE win32_obj_id;
return ev != NULL;
}
-HANDLE
+HANDLE
tty::open_output_mutex ()
{
return open_mutex (OUTPUT_MUTEX);
-}
+}
HANDLE
tty::open_input_mutex ()
{
return open_mutex (INPUT_MUTEX);
-}
+}
-HANDLE
+HANDLE
tty::open_mutex (const char *mutex)
{
char buf[CYG_MAX_PATH];
BOOL acl_exists, dummy;
TOKEN_DEFAULT_DACL dacl;
- if (GetSecurityDescriptorDacl (psd, &acl_exists,
+ if (GetSecurityDescriptorDacl (psd, &acl_exists,
&dacl.DefaultDacl, &dummy)
&& acl_exists && dacl.DefaultDacl)
{
HANDLE ptok;
if (gsid != user.groups.pgsid
&& OpenProcessToken (hMainProc, TOKEN_ADJUST_DEFAULT, &ptok))
- {
+ {
/* Set primary group to the group in /etc/passwd. */
if (!SetTokenInformation (ptok, TokenPrimaryGroup,
&gsid, sizeof gsid))
/* Conditions must match those in spawn to allow starting child
processes with ruid != euid and rgid != egid. */
else if (cygheap->user.issetuid ()
- && cygheap->user.saved_uid == cygheap->user.real_uid
+ && cygheap->user.saved_uid == cygheap->user.real_uid
&& cygheap->user.saved_gid == cygheap->user.real_gid
&& !cygheap->user.groups.issetgroups ())
{
if (strcmp (version.szCSDVersion, "Service Pack 4") < 0)
caps = &wincap_nt4;
else
- {
+ {
caps = &wincap_nt4sp4;
if (strcmp (version.szCSDVersion, "Service Pack 6") >= 0)
has_osversioninfoex = true;
os = "NT";
has_osversioninfoex = true;
switch (version.dwMinorVersion)
- {
+ {
case 0:
caps = &wincap_2000;
break;